Support

Account

Home Forums General Issues add_row doesn't work the first time Reply To: add_row doesn't work the first time

  • Because you have a repeater inside of a repeater. A group field is a repeater that always has a single row. You cannot refer to the repeater with the name “group_main_info_phones” to update the field.

    Like I said, you need to use field keys

    
    $value = array(
      // field_XXXXXXX is the field key of your nested repeater
      // it's value is an array of rows for the repeater
      'field_XXXXXXX' => array(
        // each row of the repeater is a nested array
        // that holds field key => value pairs
        array(
          // field_YYYYYYY is the field key of "name" field
          'field_YYYYYYY' => 'Jon',
          // field_ZZZZZZZ  is the field key of "phone" field
          'field_YYYYYYY' => '0897654007'
        )
      )
    );
    // field_AAAAAAA is the field key of the group field 
    update_field('field_AAAAAAA', $value, $the_record_id);