Custom Fields
Re-Envisioned
Support Meta Box Builder Conditional Logic based on selection in Checkbox List (using Meta Box Builder)

This topic contains 3 replies, has 2 voices, and was last updated by  Anh Tran 1 year, 2 months ago.

  • Creator
    Topic
  • #9992
    Resolved
    admingemo
    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 Meta Box 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #10058

    Anh 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

    admingemo
    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 Tran
    Keymaster

    Hi,

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

    View post on imgur.com

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

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.