Support

Account

Home Forums General Issues Interface support for optgroup? Reply To: Interface support for optgroup?

  • Hi @patrickzdb

    Thanks for the question. Currently, optgroup functionality is not supported into the UI textarea when editing a field.

    This said, you can use a filter called acf/load_field to modify the select field’s choices. This is detailed in the tutorial found here:
    http://www.advancedcustomfields.com/resources/tutorials/dynamically-populate-a-select-fields-choices/

    I will add this feature request to my to-do list and you can expect to see it soon.

    But for now, you will need to use this filter to modify the $field[‘choices’]

    A normal choices array looks like this:

    
    <?php 
    
    $field['choices'] = array(
    	'red' => 'Red',
    	'blue' => 'Blue'
    );
    
     ?>
    

    And an optgroup choices looks like this:

    
    <?php 
    
    $field['choices'] = array(
    	'Colors' => array(
    		'red' => 'Red',
    		'blue' => 'Blue'
    	),
    	'Shades' => array(
    		'black' => 'Black',
    		'white' => 'White'
    	),
    );
    
     ?>
    

    Hope that helps.

    Thanks
    E