Home › Forums › Backend Issues (wp-admin) › ACF repeater options used as choices in ACF field › Reply To: ACF repeater options used as choices in ACF field
Sometimes things get marked as spam for various reasons.
My understanding is that you have an options page with a repeater on it and you want to populated a select field with the values of that repeater.
because select field is a sub field in a flex field you should use the field key for your filter.
add_filter('acf/prepare_field/key=FIELD KY OF SELECT', 'populate_FIELD_NAME_from_options');
function populate_FIELD_NAME_from_options($field) {
$choices = array();
if (have_rows('repeater_name', 'options') {
while (have_rows('repeater_name', 'options') {
the_row();
$choices[get_sub_field('value_sub_field')] = $get_sub_field('label_sub_field');
}
}
$field['choices'] = $choices;
return $field;
}
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 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.