I have a Flexible Content field called “Content Blocks” for adding different types of content blocks, e.g. Paragraph, Photo Gallery, Form, etc. Inside the Form layout is another Flexible Content field called “Form Fields” for adding fields, e.g. First Name, Last Name, Email, Comments. When a new Form layout is added, I want the “Form Fields” flexible content field to automatically have the First Name and Email fields added.
The ID of the flex field is field_5f6de18aefdd9
. This is my code that’s not working:
add_filter( 'acf/load_value/key=field_5f6de18aefdd9', function( $value, $post_id, $field ) {
if ( $value !== null ) {
return $value;
}
$value = array(
array(
'acf_fc_layout' => 'first_name',
),
array(
'acf_fc_layout' => 'email',
),
);
return $value;
}, 10, 3 );
The flex sub field remains empty after adding a Form layout. Am I doing this correctly?