Support Forum
Hi, I am defining a field as require and although it is empty, I can save the post without any error, having that field empty. I am getting in the console, errors like this, but I don't know if they are related to the problem.
Here is the code with the definition of the fields
$meta_boxes[] = [
'title' => __('Hero', DOMAIN),
'id' => 'sng-hero',
'description' => __('Hero', DOMAIN),
'type' => 'block',
'icon' => 'awards',
'category' => 'sng-blocks',
'render_template' => PATH . '/gutenberg-blocks/hero/template.php',
'preview' => [
'esPreview' => '1',
'capture' => get_template_directory_uri() . '/assets/img/previews/hero.png',
],
'enqueue_assets' => function () {
},
'supports' => [
'customClassName' => true
],
'fields' => [
[
'type' => 'single_image',
'id' => 'image',
'name' => __('Imagen', DOMAIN)
],
[
'type' => 'text',
'id' => 'title',
'name' => __('Título',DOMAIN),
'required' => true
],
]
]
Greetings and thank you
Sorry for the previous errors in the post. This is the console error:
Block validation: Block validation failed for core/button
(
Content generated by save
function:
Block validation: Block validation failed for core/media-text
Content generated by save
function:
And this is the code
$meta_boxes[] = [
'title' => __('Hero', DOMAIN),
'id' => 'sng-hero',
'description' => __('Hero', DOMAIN),
'type' => 'block',
'icon' => 'awards',
'category' => 'sng-blocks',
'render_template' => PATH . '/gutenberg-blocks/hero/template.php',
'preview' => [
'esPreview' => '1',
'capture' => get_template_directory_uri() . '/assets/img/previews/hero.png',
],
'enqueue_assets' => function () {
},
'supports' => [
'customClassName' => true
],
'fields' => [
[
'type' => 'single_image',
'id' => 'image',
'name' => __('Imagen', DOMAIN)
],
[
'type' => 'text',
'id' => 'title',
'name' => __('Título',DOMAIN),
'required' => true
],
]
]
Hello there,
I see the issue when the post is still saved but the field title is empty, I can also reproduce it on my local site. But I do not see the issue with core/button
and core/media-text
like your screenshot.
If you remove the MB block, does the issue persist?
Hi again,
In local I don't reproduce the core/button, core/media-text.
The require field still doesn't work correctly and it doesn't work on custom fields of custom taxonomies either.
Hello,
Thanks, I see the issue with the validation in the block and I've escalated this issue to the development team to fix this. It will be included in the next update or so.