Required field is stored empty

Support General Required field is stored empty

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #40445
    contabilidad@sngular.com[email protected]
    Participant

    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.

    https://ibb.co/0QTZYJD

    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

    #40446
    contabilidad@sngular.com[email protected]
    Participant

    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
                ],
            ]
    ]
    #40451
    PeterPeter
    Moderator

    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?

    #40467
    contabilidad@sngular.com[email protected]
    Participant

    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.

    #40478
    PeterPeter
    Moderator

    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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.