Checkbox field

Allows the editor to set a flag using a checkbox.

myCheckboxField:
  type: checkbox

This field definition creates the following input in the control panel:

A chceckbox field in the control panel

Attributes

Property Description
defaultValue Defines the initial value of the checkbox.
group Starts a new field group.
instructions Additional instructions for this field in the control panel. Will be shown beneath the field label.
label The primary `label` of the input field in the control panel. When omitted, a label will be generated from the name of the field.
rules The validation rules of the field.
width The width of the field in the control panel.

defaultValue

Defines the initial value of the checkbox.

defaultValue: true

Templating

Printing the checkbox field returns the string :code:true or :code:false.

label: Checkbox field demo
fields:
  checkboxField:
    type: checkbox
---
{{ checkboxField }}

hasValue

Use the default :code:hasValue method to retrieve the boolean value of the checkbox.

{% if checkboxField.hasValue %}
  ...
{% endif %}