Support

Account

Home Forums Add-ons Flexible Content Field Add row and type fields on the Flexible Content Field when I save Reply To: Add row and type fields on the Flexible Content Field when I save

  • Maybe it is solved.

    update_field('cf_person', [], $post_ID); // reset row
    
    $existing_values = get_field('cf_person', $post_ID);
    
    $new_row = array(
      'acf_fc_layout' => "cf_person_set",
      'cf_person_text_ja' => 'Dummy Text'
    );
    
    if ($existing_values) {
      $existing_values[] = $new_row;
    } else {
      $existing_values = array($new_row);
    }
    
    update_field('cf_person', $existing_values, $post_ID);