Home › Forums › General Issues › add_row doesn't work the first time › Reply To: add_row doesn't work the first time
Because you have a repeater inside of a repeater. A group field is a repeater that always has a single row. You cannot refer to the repeater with the name “group_main_info_phones” to update the field.
Like I said, you need to use field keys
$value = array(
// field_XXXXXXX is the field key of your nested repeater
// it's value is an array of rows for the repeater
'field_XXXXXXX' => array(
// each row of the repeater is a nested array
// that holds field key => value pairs
array(
// field_YYYYYYY is the field key of "name" field
'field_YYYYYYY' => 'Jon',
// field_ZZZZZZZ is the field key of "phone" field
'field_YYYYYYY' => '0897654007'
)
)
);
// field_AAAAAAA is the field key of the group field
update_field('field_AAAAAAA', $value, $the_record_id);
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.