Critical - ACF Blocks V3 - field values not saved to metadata until changed
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Tái hiện vấn đề với block.json và template kết xuất PHP được cung cấp bằng WP 6.8.3 và ACF Pro 6.6.1, đồng thời so sánh blockVersion 3 với cài đặt chế độ v2. Theo dõi cách giá trị trường ban đầu và siêu dữ liệu block được lưu khi block được chèn. Hoàn thành khi các giá trị trường mặc định được lưu vào siêu dữ liệu block mà không yêu cầu thay đổi thủ công, kể cả khi InnerBlocks hiện diện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- PHP
- Star
- 946
- Fork
- 197
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AdvancedCustomFields/acf
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1041 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1038 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1034 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1032 · 1 bình luận ·
-
Drop trap, acf_after_titleĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1029 · 1 bình luận ·
Tất cả issue của AdvancedCustomFields/acf
Issue tương tự
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug Feature: Kiosk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Infrastructure: actions Module: zmscitizenapi Module: zmsentities php Type: Bug unit tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
it-at-m/eappointment#3480 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
HttpClient
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvprĐang mởdevops type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày