Support

Account

Home Forums ACF PRO load_value on a Flexible Content field within another Flexible Content field

Unread

load_value on a Flexible Content field within another Flexible Content field

  • 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?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.