Support

Account

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;
    
    	}