Boolean Field
The Boolean field type allows users to select a true/false value using a toggle switch interface.
User Interface
Editor
A toggle switch. It can be turned on or off by clicking or tapping it, like a checkbox.
Additional text can be displayed before or after the switch using the before_input and after_input options.
Preview
The preview shows the boolean value as true or false.
Data Type
A boolean. If the required option is set to false and the field is left empty, the value will be false.
Data Validation
No special validation is performed for Boolean fields as the value will always be either true or false.
Options
In addition to the common field options, the Boolean field supports the following options:
Required Options
widget
- Type:
string - Default:
string
Must be set to boolean.
Optional Options
default
- Type:
boolean - Default:
false
The default value for the field when creating a new entry.
before_input
- Type:
string - Default:
""
Text to display before the toggle switch. It’s placed at the false position.
after_input
- Type:
string - Default:
""
Text to display after the toggle switch. It’s placed at the true position.
Examples
Basic Boolean Field
Configuration example:
- name: draft
label: Draft
widget: boolean
default: true[[fields]]
name = "draft"
label = "Draft"
widget = "boolean"
default = true{
"name": "draft",
"label": "Draft",
"widget": "boolean",
"default": true
}{
name: "draft",
label: "Draft",
widget: "boolean",
default: true,
}Output example:
draft: truedraft = true{
"draft": true
}