Custom Fields
Re-Envisioned
Support MB Views Twiq if condition with Checkbox List

  • Creator
    Topic
  • #33120
    Resolved Khairul
    Participant

    Hi,

    I'm trying to display a text on MB View depending on the checkbox list value with Twig.

    For example, let's say I've created a checkbox list with choices A, B, C and D. Choices A and D are ticked in the post. I want to display the text if the checkbox list contains A.

    I tried the code below in views, however it's not working.

    
    {% if post.checkbox_list_id contains 'A' %} diplay something {% endif %}
    

    Any advice on how to proceed. Sorry, I'm new at this.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #33126
    Long Nguyen
    Moderator

    Hi,

    Thank you for reaching out.

    Here is an example to check a value in the choices of the checkbox list.

    {% set value = 'a' %}
    {% for item in post.checkbox_list %}
        {% if value in item %}
            Checked!
        {% endif %}
    {% endfor %}
    #33133
    Khairul
    Participant

    Hi,

    Perfect. Thank you so much for your help – really appreciate it.

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