I have a repeater inside of a repeater with max 1 row and I want to setup a default value for a field. I managed to find this code but seems this one works fine only for a simple repeater. Can someone help me to with the code for a repeater inside of a repeater?
add_filter('acf/load_value/name=repeater_name', 'afc_load_my_repeater_value', 10, 3);
function afc_load_my_repeater_value($value, $post_id, $field) {
if (get_post_status($post_id) === 'auto-draft') {
$value = array();
$value[] = array(
field_5890417e6fb33 => 'value1'
);
$value[] = array(
field_5890417e6fb33 => 'value2'
);
$value[] = array(
field_5890417e6fb33 => 'value3
);
$value[] = array(
field_5890417e6fb33 => 'value4'
);
$value[] = array(
field_5890417e6fb33 => 'value5'
);
}
return $value;
}
Thanks!
Try using the field key for your action instead of the field name. For nested repeaters the name used would be "{$parent_name}_{$index}_{$field_name}"
. It’s always better to use the field key, especially when dealing with sub fields.