Radio Button

Scripting Custom Views Form Helpers

The radio_tag helper tag generates a radio button. Radio buttons with the same name are part of a set, and only one of them can be checked at a time.

  • name: The input's name attribute.
  • label: Adds label text next to the radio button.
  • checked: Whether or not the radio button is checked. By default, this will be false.
  • value: The value submitted to the form when the radio button 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
{% radio_tag name: "name", label: "Radio button label!", checked: true, value: "value", id: "id" %}
HTML Output
<label class="custom-control custom-radio">
  <input name="name" id="id" value="value" type="radio" class="custom-control-input" checked="true">
  <span class="custom-control-indicator"></span>
  <span class="custom-control-description">
    Radio button label!
  </span>
</label>