Custom Fields
Support Meta Box Conditional Logic Conditional Logic with Tabs

  • Creator
  • #3232

    I’m trying to use the conditional logic extension with tabs, I would assume that this is supposed to work

    'tabs'        => array(
              'dish' => array(
                  'label' => esc_html__( 'Item Type and Details', $plugin_name ),
                  'icon'  => 'fa fa-cutlery', // Font Awesome
              'nutrient-content'    => array(
                  'label'   => esc_html__( 'Nutrient Content', $plugin_name ),
                  'icon'    => 'dashicons-screenoptions',
                  'visible'   => array( "{$prefix}menu_item_type", '=', 'item_type_a_la_carte' ),

    so essentially, the tab ‘nutrien-content’ should be only visible if menu_item_type is item_type_a_la_carte

    but the condition is not applied. Is tabs supporting conditional logic extension?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #3367
    Tan Nguyen

    Dear Nicolas,

    Thanks for using Meta Box Conditional Logic, short answer: It supports Tabs.

    Because Tabs isn’t Meta Box’s field, it’s a DOM Element so you can hide it via using DOM Selector, as already mentioned in the documentation:

    In your case, you can add this code to your theme functions.php:

    add_filter( 'rwmb_outside_conditions', function( $conditions )
        $conditions['.rwmb-tab-nutrient-content'] = [
            'visible' => ["{$prefix}menu_item_type", 'item_type_a_la_carte']
        return $conditions;
    } );

    Best regards



    Thanks, it does work by using outside conditions. I thought that adding the arg visible to the tab’s array would suffice to enable the condition. Maybe this could be done in a future update?

    Tan Nguyen

    Yeah, I’ll add it to future update as it’s nice feature. Thanks for your question 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional Logic with Tabs’ is closed to new replies.