Conditional Logic based on selection in Checkbox List (using MB Builder)

Support MB Builder Conditional Logic based on selection in Checkbox List (using MB Builder)Resolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9992
    admingemoadmingemo
    Participant

    Hello,

    I am trying to set visibility of an Advanced Select Box based on the checked value in a Checkbox List and I'm doing this via the MB Builder extension in WP admin.

    Although the doco is very clear in terms of code to achieve this (athttps://docs.metabox.io/extensions/meta-box-conditional-logic/) I am unsure what to select in the Builder UI.

    SCENARIO:

    If the user checks 'Australia' in in my list of countries (checkbox_list), then the 'State - Australia' select box (select_advanced) will appear.

    'State - Australia' select_advanced >> Advanced >> Conditional Logic - the settings in this section are as follow:
    VISIBLE when ALL of these conditions match:
    [field] [operator] [value]

    FIELD: Unsure what to put... my 'checkbox_list' ID is c_country and the individual input checkboxes all have the name c_country[] in the admin edit screen source code
    OPERATOR: = or in or contains ?
    VALUE: Unsure whether to put "Australia" or 1/true (depends on earlier field/operator)

    I have played around with a few options that I thought corresponded to the equivalent code from the docs but don't seem to be getting it right because the 'select_advanced' field is permanently visible right now.

    Any guidance on the correct settings would be great. (Personally I would be comfortable coding it instead BUT I need to get familiar with the Builder interface so I can train my team.)

    Thank you!

    #10058
    Anh TranAnh Tran
    Keymaster

    Hello, please try this:

    Field: just use c_country
    Operator: contains. The value of a checkbox list is always an array. So it should "contains" your selection.
    Value: the value of "Australia" that you set in the Options list of the c_country field.

    Please try and let me know how it goes.

    #10068
    admingemoadmingemo
    Participant

    Thanks Anh!

    Just gave that a shot (think it was one of the options I tried originally so good to know I was on the right track!) - but it does not seem to be working. 🙁

    The State (Australia) field is showing regardless of any ticked/not ticked status in Country

    Screenshot of settings and result: http://i65.tinypic.com/2zp38ro.png

    #10077
    Anh TranAnh Tran
    Keymaster

    Hi,

    I've just tried to set similar to you, and it works for me. Let me show you a video:

    https://imgur.com/a/BPQ85f1

    I also tested with tabs and it still works. Can you try again with just 2 fields?

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