Problem: I am following the tutorial to conditionally display parent posts in a CRED form:
https://toolset.com/2013/10/conditional-display-of-parent-posts-in-cred/
I would like to be able to define a default option label in my generated select field.
Solution: Add an empty option to the beginning of the list of aux_anmelder_ids in the auxiliary View:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <div id="aux_anmelder_list" style="display:none"> <div class="aux_anmelder_id"></div> <wpv-loop> <div class="aux_anmelder_id">[wpv-post-id]</div> </wpv-loop> </div> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Then change the JavaScript code to accept an empty string value instead of defaulting to zero:
$('.aux_anmelder_id', list).each(function(index, element) { var id = $(element).text(); $('option[value="' + id + '"]', select).appendTo(new_select); });
This should copy the unset value from the original select field into the cloned select field. Change the select_text attribute here from "bitte auswählen" to "wer wird angemeldet"
[cred_field field='_wpcf_belongs_person_id' value='' select_text='bitte auswählen' class='form-control' output='bootstrap']
Relevant Documentation: https://toolset.com/2013/10/conditional-display-of-parent-posts-in-cred/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 7 years ago.
Assisted by: Christian Cox.