Home › Forums › Backend Issues (wp-admin) › Dynamically populating repeater fields with default values? › Reply To: Dynamically populating repeater fields with default values?
Hi @folosophy
You should be able to do it like this:
function my_acf_set_repeater( $value, $post_id, $field ){
$value = array();
// this one should consists array of the names
$settings_values = get_field('medication_types','option');
foreach( $settings_values as $settings_value ){
$value []= array('field_1234567890abc' => $settings_value['name_field'], 'field_abc1234567890' => '');
}
return $value;
}
// acf/load_value/name={$field_name} - filter for a specific value load based on it's field name
add_filter('acf/load_value/key=field_582e290a22e62', 'my_acf_set_repeater', 10, 3);
Where “field_1234567890abc” is the name field key, “field_abc1234567890” is the value field key, and “name_field” is the name field in the “medication_types” repeater.
I hope this 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!
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.