Just a heads up. If you create a group-field and add a repeater inside it and try to follow f.ex. the Advanced example here it’s impossible to get to work. There’s something wrong with how ACF updates or references the data if you try to do it programmatically AND the repeater field is inside a Group field.
The group field is in essence a repeater field. So a repeater in a group field is actually a nested repeater. This is likely why trying to update it like a normal repeater field does not work.
Ok, gotya. Would it be possible for you to post a working example?
I have actually never used a group field and I rarely use the update functions, but there are examples of updating repeaters and nested repeaters here https://www.advancedcustomfields.com/resources/update_sub_field/
I had to get it working with the following:
update_field( 'architecture_email_sent', 'Yes', $ID);
architecture
is the name of the group.
email_sent
is the name of the field.
Yes
is the value.
$ID
is the id of the post.
That was within the have_rows
loop.
Hi, I couldn’t find an answer to this so I’ll post mine here.
My repeater is inside of a group field and I’m working outside the loop.
The post I am saving values to is also one created by wp_insert_post so the custom fields are not actually saved in the database.
You can get field keys from the edit field group page, click on screen options at the top right.
$group_key = 'field_5dc936b464376';
$repeater_key = 'field_5dc937a064379';
$sub_field_key = 'field_5dc938076437a';
$sub_field_key2 = 'field_5dc9382b6437b';
update_field( $group_key, [
$repeater_key => [
$sub_field_key => 'a',
$sub_field_key2 => 'b'
]
], $post_id);
@basthedeveloper Old topic, but thanks for the reply because it might help someone. Since this was first posted I’ve used group fields often and this is the way I would go if I wanted to update a group field with a nested repeater.