Critical - ACF Blocks V3 - field values not saved to metadata until changed
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Reproduce el problema con el block.json y la plantilla de renderizado PHP proporcionados usando WP 6.8.3 y ACF Pro 6.6.1, comparando blockVersion 3 con la configuración del modo v2. Rastrea cómo se guardan el valor inicial del campo y los metadatos del bloque cuando se inserta el bloque. Se considera completado cuando los valores de campo predeterminados se guardan en los metadatos del bloque sin requerir un cambio manual, incluso cuando está presente InnerBlocks.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- PHP
- Estrellas
- 946
- Forks
- 197
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de AdvancedCustomFields/acf
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AdvancedCustomFields/acf#1041 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
AdvancedCustomFields/acf#1038 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AdvancedCustomFields/acf#1034 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
AdvancedCustomFields/acf#1032 · 1 comentario ·
-
Drop trap, acf_after_titleAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AdvancedCustomFields/acf#1029 · 1 comentario ·
Todos los issues de AdvancedCustomFields/acf
Issues similares
-
Infrastructure: actions Module: zmscitizenapi Module: zmsentities php Type: Bug unit tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
it-at-m/eappointment#3480 ·
Los mantenedores suelen responder en 1 día
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvprAbiertodevops type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
needs approval
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 3 días
-
product / avatars product / self-hosted product / storage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
appwrite/appwrite#13985 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día