Home › Forums › General Issues › Disable Options for Select Field › Reply To: Disable Options for Select Field
What should increasing the priority to 20 change?
From the “class-acf-field-select.php” i see that there isn’t an possibility to “disable” options.
The select itself use the “disable” in line 318.
if( !empty($field['disabled']) ) $select['disabled'] = 'disabled';
the select itself is rendered via
acf_select_input( $select );
which is in acf-input-functions.php
acf_get_select_input calls acf_walk_select_input($choices, $value)
where the “option tags are rended with “value”, “selected” and “data-i” attributes.
So no “disabled” html attribute.
// single (option)
} else {
$attrs = array(
'value' => $value
);
// If is selected.
$pos = array_search( esc_attr($value), $values );
if( $pos !== false ) {
$attrs['selected'] = 'selected';
$attrs['data-i'] = $pos;
}
$html .= sprintf( '<option %s>%s</option>', acf_esc_attr($attrs), esc_html($label) );
}
If there would be a way to access the form “post_id” to filter function of the field i could delete the “not wanted options” from the array when post_id is e.g. “new_post”.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.