Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic Not working with conditional check from inside group

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 4 months, 1 week ago.

  • Creator
    Topic
  • #14522

    aaron
    Participant

    I have a page builder style metabox area and for some reason the visibility doesn’t toggle for the group items.

    I’m trying to show / hide the single_image field depending on a selection from the select_advanced metabox, But this condition doesn’t perform any checks:
    'visible' => ["{$builder_prefix}style", 'image_top_text_below'],

    /**
             * Layout: Columns
             */
            array(
                'name'    => 'Column Style',
                'id'      => "{$builder_prefix}style",
                'type'    => 'select_advanced',
                'options' => array(
                    'image_top_text_below' => 'Image top, text below',
                    'text_with_background' => 'Text with background',
                ),
                'multiple'    => false,
                'placeholder' => 'Choose your layout',
            ),
            array(
                'name'    => 'Column Count',
                'id'      => "{$prefix}column_count",
                'type'    => 'radio',
                'inline'    => 'true',
                'options' => array(
                    '2' => '2',
                    '3' => '3',
                ),
            ),
    
            // Columns Group
            array(
                'id'     => "{$column_prefix}group",
                'type'   => 'group',
                'clone'  => true,
                'sort_clone' => true,
                'collapsible' => true,
                'save_state' => true,
                'default_state' => 'expanded', 
                'group_title' => array('field' => "{$column_prefix}title" ),
                'add_button' => '+ Column',
                'fields' => array(
                    
                    array(
                        'name' => 'Column Image',
                        'id'   => "{$column_prefix}image",
                        'type' => 'single_image',
                        'visible' => ["{$builder_prefix}style", 'image_top_text_below'],
                    ),
                    array(
                        'name' => 'Column Title',
                        'id' => "{$column_prefix}title",
                        'type' => 'text',
                    ),
                    array(
                        'name' => 'Column Text',
                        'id'   => "{$column_prefix}text",
                        'type' => 'wysiwyg',
                        'raw'  => false,
                        'options' => array(
                            'textarea_rows' => 3,
                            'teeny'         => true,
                            'media_buttons' => false,
                        ),
                    ),
                ),
            ), // end Group
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #14532

    Anh Tran
    Keymaster

    Hi aaron,

    The problem here relates to the scope of the conditions. When a condition is put on a field that inside a cloneable group, the plugin sets the scope = the group. So it searches for elements inside the group only.

    In this case, the scope of the condition for the field “Column Image” is the group. And the plugin can’t search outside it.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.