Accueil › Toolset Professional Support › [Résolu] CRED: blank/empty default value for taxonomy select field
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.
Marqué : Content-submission forms, Toolset Forms
Documentation connexe :
This topic contains 3 réponses, has 2 voix.
Last updated by Waqar Il y a 6 mois.
Assigned support staff: Waqar.
I found this from 8 years ago: https://toolset.com/forums/topic/cred-blank-default-value-for-taxonomy-select-field-validation/
I want to have a taxonomy field with no default value. Currently, my select dropdown defaults to the first option.
I have tried this, but it doesn't work:
[cred_field field='country' force_type='taxonomy' output='bootstrap' display='select' single_select='true' default_label=""]
How do I have an empty value by default for the dropdown?
Anglais (English )
Thank you for contacting us and I'd be happy to assist.
Currently, there is no built-in parameter, to insert a default empty option in the taxonomy select field in the form.
We have an internal ticket to introduce this and I've added your voice to this feature request as well.
For now, a workaround can be to include some custom script in your form's "JS editor". For example:
jQuery("select[name='country']").prepend('<option value="">- Select -</option>');
jQuery("select[name='country']").selectedIndex = 0;
Note: Please replace "country" with your actual taxonomy's slug.
How do I force the user to make a selection?
doesn't exactly work, I guess because it sees - Select - as a valid selection?
Thanks for writing back.
I've tested this script on my website and it works to make the select field required:
jQuery("select[name='category']").prepend('<option value="">- Select -</option>');
jQuery("select[name='category']").selectedIndex = 0;
Known issues and solutions
Frequently asked support questions
Support tickets archive
Get help from experienced contractors
Meet Toolset support team
Toolset Customer Support Policy
Need to tell us something about the quality of support
How to remove personal information from your database for support