Hi,
Added this as a support ticket too.
We’re using ACF Pro on the front end of a website. Rather than use ACF’s add_form, we’re creating our own UI.
We’re having trouble adding a flexible content row within a repeater field. We use buttons to create each layout, that are already created in ACF. When we click a button we can create the first row using the following:
$selector = 'repeater_0_flexible';
$fieldKey = 'field_5039a99716d1d';
$field = get_field($selector);
$field[] = 'layout1';
update_field( $selector, $field, $post_id );
update_post_meta($post_id, '_'.$selector, $fieldKey);
This appears to function perfectly and in the db we see a:1:{i:0;s:7:”layout1″;} for the post_meta for the meta_key ‘repeater_0_flexible’.
However, when we try to add a second flexible content layout we’re having issues. Currently we’re trying:
$field = get_field($selector); // this returns null for some reason??
$field[] = array('acf_fc_layout' => $acfLayout);
add_row( $selector, $field, $post_id );
The result is that the data gets corrupted and both flexible fields disappear. We now see 2 as the post_meta for the meta_key ‘repeater_0_flexible’. get_field() at this point returns null for some reason.
Any thoughts on what we can try?