Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Critical - ACF Blocks V3 - field values not saved to metadata until changed #984

@smerriman

Description

@smerriman

Describe the bug
When using v3 blocks, field values are not saved to the block metadata until a field value is specifically changed. This results in effects such as default values not working.

To Reproduce
Steps to reproduce the behavior:

  1. Create the block and field group via the code below.
  2. Add a new post, and insert the block. You will see the checkbox is checked, and the get_field code outputs that it is checked.
  3. Publish the post, and view it on the front-end. It says the checkbox is not checked.
  4. Reload the editor, and it will also say it is not checked.
  5. Click on the block to edit it, and the editor preview will quickly changed to checked again.
  6. During any stage of the above, switch to the code editor, and see the block metadata is empty.
  7. Repeat all of the above, replacing "blockVersion": 3 with "mode":"preview" in block.json, to show that it used to work correctly in v2 blocks.

Note that if you remove the InnerBlocks line from the render template, you get slightly different results - the preview shows correctly in the editor even without clicking the block, but it still doesn't save.

Only by unchecking and then rechecking the checkbox will it save.

Expected behavior

Block fields should be saved to the block when first inserted.

Screenshots or Video

2025-10-29.10-58-22.mp4

Code
Field export:

    {
        "key": "group_68d08a422dee3",
        "title": "Test block",
        "fields": [
            {
                "key": "field_68d08a4483410",
                "label": "Test field",
                "name": "test_field",
                "aria-label": "",
                "type": "true_false",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "message": "Test field",
                "default_value": 1,
                "allow_in_bindings": 0,
                "ui": 0,
                "ui_on_text": "",
                "ui_off_text": ""
            }
        ],
        "location": [
            [
                {
                    "param": "block",
                    "operator": "==",
                    "value": "acf\/testblock"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": true,
        "description": "",
        "show_in_rest": 0,
        "display_title": ""
    }
]

block.json:

{
    "name": "acf/testblock",
    "title": "Test block",
    "acf": {
	    "renderTemplate": "testblock.php",
        "blockVersion": 3
    }
}

render template:

<p><?php if (get_field('test_field')) echo 'Checkbox is checked'; else echo 'Checkbox is not checked'; ?></p>
<InnerBlocks />

Version Information:

  • WP 6.8.3
  • ACF Pro 6.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions