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