MB Conditional Logic not working in MB Blocks (Normal Context)

Support MB Conditional Logic MB Conditional Logic not working in MB Blocks (Normal Context)

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

    Hi,

    I'm experiencing an issue with MB Conditional Logic and MB Blocks following the most recent update.

    Conditional logic has stopped working inside the modal window of a block when the context is set to normal.

    When opening the modal to edit the fields, the conditional logic is ignored—fields that should be hidden are either permanently hidden or the logic simply doesn't trigger when values change.

    The fields inside the modal should respect the conditional logic rules, hiding or showing based on the defined dependencies, as they did in previous versions.

    Is this a known bug in the latest release? Any temporary workaround or fix would be greatly appreciated.

    Best regards,

    #49843
    PeterPeter
    Moderator

    Hello,

    Thanks for reaching out.

    How do you create the modal with custom fields when editing the post? Can you please share a screen record of the issue and share the JSON field group after exporting?
    Following the documentation https://docs.metabox.io/extensions/meta-box-builder/#export--import

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

    Hi,

    I’m providing the block details for reference. As you can see, there are fields conditioned to the 'Formulario' checkbox. When checked, these fields should be visible, but they remain hidden.

    Interestingly, if I change the attribute to 'context' => 'aside', the conditional logic works perfectly. The issue only occurs when using 'context' => 'normal'.

    Best regards.

    
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title'                     =>    __('Hero Landing', THEME_DOMAIN),
            'id'                        =>    'hero-landing',
            'description'               =>    __('Hero Landing', THEME_DOMAIN),
            'type'                      =>    'block',
            'icon'                      =>    'awards',
            'category'                  =>    'blocks',
            'enqueue_assets' => function () {
                wp_enqueue_style('theme-header', get_template_directory_uri() . '/assets/css/main.css');
                wp_enqueue_style('theme-icons-header', get_template_directory_uri() . '/assets/css/icons.css');
            },
            'render_template'           =>    THEME_DIR_PATH . '/gutenberg-blocks/hero-landing/template.php',
            'preview'                   => [
                'esPreview' => '1',
                'capture' => get_template_directory_uri() . '/assets/img/hero-landing.png',
            ],
            'supports'                  => [
                'customClassName'   =>    true
            ],
            'context'         => 'normal',
            'fields'                    => [
                [
                    'type' => 'text',
                    'id'   => 'id',
                    'name' => __('Identificador', THEME_DOMAIN),
                ],
                [
                    'type' => 'text',
                    'id'   => 'class_style',
                    'name' => __('Clase CSS', THEME_DOMAIN),
                ],
                [
                    'type' => 'single_image',
                    'id'   => 'image',
                    'name' => __('Imagen Fondo', THEME_DOMAIN),
                ],
                [
                    'name'          => __('Color Fondo Tarjeta', THEME_DOMAIN),
                    'id'            => 'background_card',
                    'type'          => 'color',
                    'alpha_channel' => true,
                    'js_options'    => [
                        'palettes' => [
                            '#4066ff', 
                            '#1c46eb', 
                            '#0027c2', 
                            '#0021a6', 
                            '#001a80', 
                            '#f2faff', 
                            '#e0f2ff', 
                            '#bde0f8', 
                            '#8fbcdb', 
                            '#6b9dbf',
                        ],
                    ],
                ],
                [
                    'type' => 'wysiwyg',
                    'id'   => 'text',
                    'name' => __('Contenido Tarjeta', THEME_DOMAIN),
                    'raw'  => true,
                    'options' => [
                        'textarea_rows' => 4,
                        'teeny'         => true,
                    ]
                ],
                [
                    'name' => __('¿Formulario?', THEME_DOMAIN),
                    'id'   => 'is_form',
                    'type' => 'checkbox',
                    'std'  => 0
                ],
                [
                    'name'          => __('Color Fondo Tarjeta', THEME_DOMAIN),
                    'id'            => 'background_form',
                    'type'          => 'color',
                    'alpha_channel' => true,
                    'js_options'    => [
                        'palettes' => [
                            '#4066ff', 
                            '#1c46eb', 
                            '#0027c2', 
                            '#0021a6', 
                            '#001a80', 
                            '#f2faff', 
                            '#e0f2ff', 
                            '#bde0f8', 
                            '#8fbcdb', 
                            '#6b9dbf',
                        ],
                    ],
                    'hidden' => ['is_form', '!=', 1]
                ],
                [
                    'name' => __('Titulo Formulario', THEME_DOMAIN),
                    'id'   => 'form_title',
                    'type' => 'wysiwyg',
                    'raw'  => true,
                    'options' => [
                        'textarea_rows' => 4,
                        'teeny'         => true,
                    ],
                    'hidden' => ['is_form', '!=', 1]
                ],
                [
                    'type' => 'text',
                    'id'   => 'short_code',
                    'name' => __('Codigo Formulário', THEME_DOMAIN),
                    'hidden' => ['is_form', '!=', 1]
                ],
            ]
        ];
    
        return $meta_boxes;
    });
    

    https://imgur.com/a/YVAQ112
    https://imgur.com/SyL35RU

    #49853
    PeterPeter
    Moderator

    Hello

    I can reproduce the issue on my demo site and I've escalated the issue to the development team to fix it as soon as possible.
    In the meantime, you can use the context side to make the conditional logic works properly.

    Thank you.

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