Home › Forums › Backend Issues (wp-admin) › Duplicated ACF Blocks in Widgets failing to save/render correctly
When duplicating an ACF block (registered with
ACF Pro 5.10.2
1. Create ACF Field Group
acf_add_local_field_group(array( 'key' => 'group_614c3a15115de', 'title' => 'Test Block', 'fields' => array( array( 'key' => 'field_614c3c7d9b75e', 'label' => 'Test Field', 'name' => 'test_field', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', ), ), 'location' => array( array( array( 'param' => 'block', 'operator' => '==', 'value' => 'acf/test-block', ), ), ), 'menu_order' => 0, 'position' => 'acf_after_title', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => true, 'description' => '', 'is_acf_component' => 0, 'acf_component_defaults' => array( 'repeatable' => '0', 'min' => '', 'max' => '', 'layout' => 'block', 'button_label' => '', 'appearances' => '', ), ));
2. Register ACF Block
acf_register_block_type(array( 'name' => 'test_block', 'title' => __('Test Block'), 'description' => __('Test Block'), 'render_template' => 'template-parts/content_builder-test.php', 'category' => 'formatting', ));
3. Create template file in
render_template location with the contents:
3. Navigate to Widgets
4. Add new ‘Test Block’
5. Duplicate ‘Test Block’ a few times.
6. Edit the contents of the fields, toggle between Edit/Preview.
## Expected Result
All fields and admin elements should work as normal.
## Actual Result
The preview does not align with the content, when switching back to edit, the value in the field may have changed too. The ‘Update’ button often is not triggered to an active state. When managing to save, reloading shows the widgets in a different state to when you left it.
Copying the contents into a reusable block, editing then copy/pasting back in does not work. (Reusable blocks are not supported in the Widgets interface just yet.)
## Work around
Create all blocks from scratch within the widgets interface.
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 demoed ACF 6.1 Beta during the most recent session of ACF Chat Fridays, highlighting the new ability to regenerate and clear labels, setting the Admin Menu Parent as a slug, and more. Catch the video replay in our latest summary. https://t.co/rHEpPVas64 pic.twitter.com/hB1XKTexXi— Advanced Custom Fields (@wp_acf) March 23, 2023
© 2023 Advanced Custom Fields.