Toggle

Toggle

{{ toggle }}

Properties of {{ toggle }} objects
Name Type Description
is_valid Boolean Always true
value String on_value or off_value
default_value String The default value for this field if no value is specified
on Boolean True if the toggle is "on". False if it is "off"
on_label String The text to be displayed when the toggle is "on"
on_value String The value represented by the "on" position
on_color String The color of the toggle when it is "on" (could be any valid CSS color)
off_label String The text to be displayed when the toggle is "off"
off_value String The value represented by the "off" position
off_color String The color of the toggle when it is "off" (could be any valid CSS color)
field_id String The identifier for this field
label String The label for this field
output String on_label or off_label. May include additional markup in the editor preview to make it easier to edit content

Represents an on/off toggle control

Related

{{ text }}

string

Can be any text, from the empty string ("") to the full HTML output of the template. When used alone in a conditional, all strings evaluates as true - even if they are empty or a value such as "0" or "false".

{% toggle_automatic_markup %}

Enables or disables the automatic markup at the page level

boolean

True or False

Examples

Check whether a toggle (boolean) field is on before showing content or saving state.

Check if a toggle (boolean) field is on

Copy
<p>Show subscriptions? <strong>{{ entity.show_subscription_form }}</strong></p>
{%- if entity.show_subscription_form.on -%}
{%- include "Subscription Form" -%}
{%- endif -%}