Home Forums Add-ons Repeater Field Update field in repeated field within group Reply To: Update field in repeated field within group

  • The first thing that you need to do is use field keys when updating acf field values for a post that has been inserted that does not already have values. There is a short explanation of this in the documentation.

    When updating a group field or a repeater field you need to use the correct structure for the array. In your case you would update the group field with an array containing all of the sub fields that you want to update.

    // let's assume that the field key of the group is field_GGGGGGG
    $group_key = 'field_GGGGGGG';
    $value = array(
       // the value off a group is an array
       // consisting of "field key" => "sub field value" pairs
       // assume field_TTTTTTT is a text field
       'field_field_TTTTTTT' => 'value of text field',
       // assume that field_RRRRRRR is a repeater
       'field_RRRRRRR' => array(
          // a repeater value is an array
          // each nested array is a row in the repeater
            // each element of the row contains
            // "sub field key" => "sub field value" pairs
            'field_1111111' => 'sub field 1 value'
            'field_2222222' => 'sub field 2 value'
            // etc....
    update_field($group_key, $value, $post_id);