Critical - ACF Blocks V3 - field values not saved to metadata until changed
まだ誰も着手していません。
評価
調査の方向性
提供された block.json と PHP レンダーテンプレートを使用し、WP 6.8.3 および ACF Pro 6.6.1 で問題を再現して、blockVersion 3 と v2 モード設定を比較します。ブロックの挿入時に、初期フィールド値とブロックメタデータがどのように保存されるかを追跡します。InnerBlocks が存在する場合も含め、手動で変更しなくてもデフォルトのフィールド値がブロックメタデータに保存されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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:
- Create the block and field group via the code below.
- 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.
- Publish the post, and view it on the front-end. It says the checkbox is not checked.
- Reload the editor, and it will also say it is not checked.
- Click on the block to edit it, and the editor preview will quickly changed to checked again.
- During any stage of the above, switch to the code editor, and see the block metadata is empty.
- Repeat all of the above, replacing
"blockVersion": 3with"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
https://github.com/user-attachments/assets/5dc16eae-0ff7-42a2-9194-06bbc0b5ec5d
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
- 主要言語
- PHP
- スター
- 946
- フォーク
- 197
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AdvancedCustomFields/acf のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
AdvancedCustomFields/acf#1041 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
AdvancedCustomFields/acf#1038 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
AdvancedCustomFields/acf#1034 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
AdvancedCustomFields/acf#1032 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
AdvancedCustomFields/acf#1029 · コメント 1 件 ·
AdvancedCustomFields/acf の issue をすべて見る
似ている issue
-
UX
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ProfessionalWiki/NeoWiki#1573 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信