Checkboxes Fields

Checkboxes fields give you a group of checkboxes.



Checkboxes fields have the following settings:

  • Checkbox Options – Define the checkboxes that will be available in the field. You even get to set the option values and labels separately, and choose which ones should be checked by default.

The Field

Checkboxes fields will show each of the checkbox options as defined in the field settings:



If you only have one checkbox, and you just want to tell if it has been selected, you can do that using the length filter:

{% if entry.checkboxFieldHandle | length %}

You can loop through your selected options like so:

    {% for option in entry.checkboxFieldHandle %}
        <li>{{ option }}</li>
    {% endfor %}

Or you can loop through all of the available options rather than just the selected ones:

    {% for option in entry.checkboxFieldHandle.options %}
        <li>{{ option }}</li>
    {% endfor %}

In either case, you can output an option’s label by typing {{ option.label }} instead, and you can tell if the option is selected or not via option.selected.

You can also tell if a particular option is selected outside the scope of looping through the options like so:

{% if entry.checkboxFieldHandle.contains('tequila') %}
{% endif %}

If you are including a Checkboxes field on a front-end entry from, make sure to include a hidden input before the checkboxes, so that an empty value is submitted if no checkboxes are checked.

<input type="hidden" name="fields[checkboxFieldhandle]" value="">

    <li><input type="checkbox" name="fields[checkboxFieldHandle][]" value="foo">{{ checkboxOption.label }}</li>
    <li><input type="checkbox" name="fields[checkboxFieldHandle][]" value="bar">{{ checkboxOption.label }}</li>