Support

Account

Home Forums Add-ons Repeater Field How to add new row in repeater under some group programatically Reply To: How to add new row in repeater under some group programatically

  • I have found a solution:

    We can use update_field to add new rows to a repeater inside a group.

    1. Get all values of the fields inside that group
    2. Manipulate the resulting array adding new values in the repeater’s array
    3. Update the group field.

    It works even if the repeater never had any rows.

    $pachet_8 = get_field("pachet_8", $post_id);
    		
    $pachet_8['rata_3']['plati'][] = array(
    													"suma" => 1001,
    													"data_platii" => "10.10.2018"															
    													);
    		
    update_field("pachet_8", $pachet_8, $post_id);