Custom Fields
Re-Envisioned
Support MB Blocks Using the value of a switch field in a twig if statement

  • Creator
    Topic
  • #32951
    Resolved Kyle Melton
    Participant

    Hi,

    I am trying to create an if statement using a switch field but it seems to not render.

    Here is what I have tried for the beginning of the statement:

    The switch field has an ID of "multiple_switch"

    {% if multiple_switch == 1 %}

    {% if multiple_switch == '1' %}

    {% if multiple_switch == "1" %}

    {% if multiple_switch == true %}

    All of the above either do nothing or show the content regardless of the switch setting.

    Is there something I am overlooking?

    Thank you!

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

    Hi Kyle,

    The field switch returns the value On/Off, please compare it with that value.

    {% if multiple_switch == "On" %}
    
    #32956
    Kyle Melton
    Participant

    Hi Long,

    Thank you for the clarification.

    I assumed it had to be a 1 or a 0 because of this part of the documentation:

    Data
    This field saves the “on” and “off” status in the database as “1” or “0”.

    Thanks again!

    Kyle

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