Support

Account

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”.