Home › Forums › General Issues › Disabled option for select fields › Reply To: Disabled option for select fields
I’m suggesting adding a to the field choices for example
$field['choices'] = array( '' => 'This value is NULL'. 1 => 'This is a valid value' );
Any array index of ” does work in PHP and this is what ACF uses for the value. The rest of it should be handled by ACF. The empty string index cannot be added through the ACF field setting, but I think it could be added in PHP.
But your idea will work as well. You can have a set of values in the field settings like
not allowed : select your occupation butcher baker candle stick maker
Then you can create an acf/validate_value filter for your field that displays an error if that value is selected https://www.advancedcustomfields.com/resources/acf-validate_value/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.