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