Home › Forums › Add-ons › Flexible Content Field › Extend flexible content layouts with acf/load_field
Hey,
we building a theme framework with ACF Pro. Our page builder uses ACF flexible contents. We want to build plugins that extend our page builder with new fields (e.g. teams module).
My idea was to use the acf/load_field filter to add more “layouts” to the field. It works great – BUT! not with clone fields.
In our page builder we load global settings (that fits to every page builder item) with a clone field. So if we add new layouts with clone fields, the fields are empty.
I tried to loading the clone fields by json or php. It makes no difference. Here is my code:
add_filter( 'acf/load_field/name=page_builder', 'team_registerPageBuilder' );
function team_registerPageBuilder( $field ) {
$sectionKey = xcore_generate_acf_key( 'team' );
$fields = [
'key' => 'layout_' . $sectionKey,
'name' => 'page_builder_modules_team',
'label' => 'Team',
'display' => 'block',
'sub_fields' => [
array(
'key' => 'field_604a13e5a4a9b',
'label' => 'General',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_604a13efa4a9c',
'label' => 'General clone',
'name' => 'general_clone',
'type' => 'clone',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'clone' => array(
0 => 'group_6049f5c25d549',
),
'display' => 'seamless',
'layout' => 'block',
'prefix_label' => 0,
'prefix_name' => 0,
)
],
'min' => '',
'max' => '',
];
$field['layouts'][ 'layout_' . $sectionKey ] = $fields;
return $field;
}
The global field group is “group_6049f5c25d549” and exists. It works great for layouts generated directly in the original fiel group of our page builder.
Any hint for me?
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.