Conditional Logic and Tabs

Support MB Conditional Logic Conditional Logic and Tabs

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36141
    LucaLuca
    Participant

    I have created several tabs with your builder (I use Metabox AIO) and would like to show and hide them depending on what is selected in a check list. I've tried using conditional logic but it doesn't work with the tabs, what can I do? I read this but it didn't help me much: https://docs.metabox.io/hide-tabs-with-conditional-logic/

    #36153
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please share the code that creates tabs, custom fields and the code that shows/hides the tab? I see it still works on my site.

    #36155
    LucaLuca
    Participant

    I did not use the code, I used the builder, shall I send the screenshots of the builder?

    #36162
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The conditional logic for tabs is not supported in the builder for now. You can use the custom code in the article to show/hide the tab. Something like

    add_filter( 'rwmb_outside_conditions', function( $conditions ) {
        $conditions['.rwmb-tab-interest'] = array(
            'hidden' => array( 'post_format', 'aside' ),
        );
        return $conditions;
    } );
    #36214
    LucaLuca
    Participant

    Thank you, I had already seen this code on the support page and it unfortunately did not clarify it for me.
    I have a checkbox list with these values:
    disable_first_blue_band: Disable First blue band
    disable_second_content_section: Disable Second Content Section
    disable_partner_section: Disable Partner Section

    I would like to check
    disable_second_content_section: Disable Second Content Section

    would hide the tab:
    Second Content Section
    tab_4er7e4xyg9g

    Could you provide me with an example closer to my specific case?
    I can put the code above directly into the function.php right?

    #36227
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The PHP code in the article only works with the checkbox field, a simple field with a single value. Assume that the checkbox field has the ID checkbox_wdpmzjmthr, then the code to hide the tab would be

    add_filter( 'rwmb_outside_conditions', function( $conditions ) {
        $conditions['.rwmb-tab-tab_4er7e4xyg9g'] = array(
            'hidden' => array( 'checkbox_wdpmzjmthr', 'disable_second_content_section' ),
        );
        return $conditions;
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.