Checkbox

Scripting Custom Views Form Helpers

The checkbox_tag helper tag generates a checkbox.

  • name: The input's name attribute.
  • label: Adds label text next to the checkbox.
  • checked: Whether or not the checkbox is checked. By default, this will be false.
  • value: The value submitted to the form when the checkbox is checked. By default, this will be "true".
  • id: The input's ID attribute. By default this will be set to the name, converted into a variable_name-style string.
Helper Tag
{% checkbox_tag name: "name", label: "Checkbox label!", checked: true, value: "value", id: "id" %}
HTML Output
<label class="custom-control custom-checkbox">
  <input name="name" id="id" value="value" type="checkbox" class="custom-control-input" checked="true">
  <span class="custom-control-indicator"></span>
  <span class="custom-control-description">
    Checkbox label!
  </span>
</label>