Home › Forums › General Issues › Updating Sub Field of Group Inside a Repeater › Reply To: Updating Sub Field of Group Inside a Repeater
I noticed an extra closing curly bracket. Not sure if that is it.
I think your group field is like a repeater. I haven’t work with this field type, so I’d be guessing. I think you have to put if/while for your group inside your first repeater.
The documentation is here:
Group
In other words, the group is nested in the repeater.
I think the code should look something like this:
function my_check_for_change($value, $post_id, $field) {
if( have_rows('r1') ):
while( have_rows('r1')) : the_row()
if( have_rows('g1') ):
while( have_rows('g1')) : the_row()
update_sub_field( array('r1', 1, 'g1', 1, 't1'), 'cow' );
update_sub_field( 't1', 1, 'cow');
update_sub_field( 'g1_t1', 1, 'cow');
update_sub_field( 'r1_g1_t1', 1, 'cow');
endwhile;
endif;
endwhile;
endif;
}
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 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.