Home › Forums › Backend Issues (wp-admin) › Dynamically populate a select field’s choices – define defaults › Reply To: Dynamically populate a select field’s choices – define defaults
Yes there is. $field also has the index ‘default_value’
On fields that allow a single choice return set it to a string.
$field['default_value'] = 'my value'; Note, this could be for ACF4, at least I set single default values with a string and it works
for fields that allow multiple choices return an array that holds the list of choices, you can also return an array of one choice for single item fields.
$field['default_value'] = array ( 'value one' => 'value one', 'value two' => 'value two', );
Any time you want to know what you can set and what index of $field you need to alter to dynamically load it with a filter the best bet is to create a test field and then use the export feature to see what elements make the $field value. Any of the elements that are exported can be altered by your filter.
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!