Radio Buttons Field

Allow selection of a single item from a group of radio buttons

Options#

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

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

  • Order – Order the radio buttons as desired.

Use#

Radio buttons by their nature only allow for the selection of a single input

Template Use#

Access your radio button fields via the handle you set for the field. Each radio button field provides an array accessed via radioButtonsFieldHandle which contains the radio buttons stored in the field, sorted in the order set by the field options.

The loop

{% for rb in entry.yourFieldHandle.radioButtonsFieldHandle %}

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

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

    <p>Selected? : {{ rb.selected }}</p>

{% endfor %}

Radio Button Properties

  • name - The name of the radio button.
  • value - The value of the radio button.
  • selected - Whether the radio button was selected.

Calling the field with no properties will return the selected value automatically

<p>Value selected was {{ entry.yourRadioButtonFieldHandle }}</p>

To determine if a particular radio button was selected just test the selected property.

{% for rb in entry.yourFieldHandle.radioButtonsFieldHandle %}

    {% if rb.selected %}

        <p>{{ rb.name }} with {{ rb.value }} was selected!</p>

    {% else %}

        <p>{{ rb.name }} with {{ rb.value }} was not selected!</p>

    {% endif %}

{% endfor %}