I’m sorry too, for not being clearer.
I put a select sub-field in a repeater field. And I need to know how to write the function for it, in that it’s loading now into a sub-field.
This is how I did it before when select was a field.
//Dynamically populate a select field’s choices in ACF
function my_acf_load_field( $field )
// reset choices
$field[‘choices’] = array();
// load repeater from the options page
// loop through the repeater and use the sub fields “value” and “label”
$value = get_sub_field(‘value’);
$label = get_sub_field(‘label’);
$field[‘choices’][ $value ] = $label;
// Important: return the field
Does anything change?
Thank you for your time and patience. I’ll try to make it more clear.
I have a repeater field in a field group. One of the subfields in that repeater group is a Select field type. I can’t get it to dynamically populate.
How should I change my function coding to get it to recognize a subfield Select? Or is this possible?
Hi @tim Triplett
The issue here is most likely that your filter is not running. Have you added some debug code to your function to make sure it is running?
Perhaps also try using the sub field’s
key instead of it’s
name when adding the function to the filter like so:
Please note, the filter should use the name or key of the SUB FIELD, not the repeater field.
The topic ‘Dynamically populate a select subfield in a repeater field’ is closed to new replies.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.