Checkboxes Field

Check box fields allow for multiple name/value pairs to be presented and selected.

Options#

  • Add name/value pairs – Add any number of name/value pairs to be included in the check box field.

  • Set a default – If desired, set which check boxes should be by default checked when the field is first used.

  • Order – Order the check boxes as desired.

Use#

If the field has been set to required then the entry will not be update-able until at least one checkbox has been checked.

Template Use#

Access your checkbox fields via the handle you set for the field. Each checkbox field provides an array accessed via checkboxFieldHandle which contains the checkboxes stored in the field, sorted in the order set by the field options.

The loop

{% for cb in entry.yourFieldHandle.checkboxFieldHandle %}

    <p>Name : {{ cb.name }}</p>

    <p>Value : {{ cb.value }}</p>

    <p>Checked? : {{ cb.checked }}</p>

{% endfor %}

Checkbox Properties

  • name - The name of the checkbox.

  • value - The value of the checkbox.

  • checked - Whether the checkbox was checked.

To determine if a particular checkbox was checked just test the checked property:

{% set firstCheckBox = entry.yourFieldHandle.checkboxFieldHandle[0] %}

{% if firstCheckBox.checked %}

    <p>{{ firstCheckBox.name }} was selected!</p>

{% else %}

    <p>{{ firstCheckBox.name }} was <b>not</b> selected!</p>

{% endif %}