Checkboxes

Create — you guessed it — checkboxes! The selected checkboxes are stored as an array. Keep that in mind when using the data in your templates.


Preview

Checkboxes Fieldtype

Usage

Use the options setting to define a list of values and labels.

favorites:
  type: checkboxes
  instructions: Choose up to 3 favorite foods.
  options:
    donuts: Donuts
    icecream: Ice Cream
    brownies: Brownies

You may omit the labels and just specify keys. If you use this syntax, the value and label will be identical.

  options:
    - Donuts
    - Ice Cream
    - Brownies

Data Structure

The values in the screenshot would saved as a simple list:

favorites:
  - donuts
  - icecream

If you only specified values for the options array, then the labels will be saved.

favorites:
  - Donuts
  - Ice Cream

Templating

Since the data is saved as a simple list, you can use a tag pair to iterate over the values or use an array modifier:

<ul>
{{ favorite }}
    <li>{{ value }}</li>
{{ /favorite }}
</ul>
{{ favorite | ul }}
<ul>
    <li>donuts</li>
    <li>icecream</li>
</ul>

Settings

This fieldtype supports the following settings in addition to the defaults.

options

array

Sets of key/value pairs that define the values and labels of the checkbox options.

Last modified on October 18, 2017