Radiogroup

With the radiogroup tag you can add radio buttons to your templates.

The radiogroup tag allows you to create radio buttons. A radio button is most commonly used to present the different answers to a question, where you are only allowed to pick one. In function, it's fairly similar to the dropdown input. Visually a radio input closer resembles a boolean. Booleans are however only used to capture true/false.

Radiogroups behave like regular input tags; they are used to create custom variables that allow users to store data on the template. The code syntax is a bit different however.

Every radio button needs to be wrapped inside the radiogroup tag, because only one value can be stored per group of radio buttons.

What's your favorite music genre?
{% radiogroup custom.music.fav_genre default:"pop" %}
  {% radioinput label:"Folk" value:"folk" %}
  {% radioinput label:"Jazz" value:"jazz" %}
  {% radioinput label:"Pop" value:"pop" %}
  {% radioinput label:"Metal" value:"metal" %}  
{% endradiogroup %}

The tag "radiogroup" is always followed by the name of the custom variable.

{% radiogroup custom.namespace.key %}{% endradiogroup %}

Radiogroup also accepts common input attributes, such as required, default and import_title.

{% stripnewlines %}
  Do you know BTS?
  {% radiogroup custom.music.bts_famous required:true %}
    {% radioinput label:"Yes" value:"yes" %}
    {% radioinput label:"No" value:"no" %}
  {% endradiogroup %}
{% endstripnewlines %}

πŸ“˜

Default and required attributes

As with other inputs, there's no point in making an input required if you apply a default. While the default value is not stored in the database, visually it looks like the question has already been answered and it's not mandatory for the user to take action.

Radioinput

Each radio button is defined by the radioinput tag. A radiogroup technically needs at least 1 radioinput.
Every radioinput needs a value, within the same radiogroup the values should be unique. The value will be stored on the template as a string.

You can also add a label, which will be displayed next to the radio button. If there's no label, the value will be displayed instead.

What's your favorite instrument?
{% radiogroup custom.music.instrument default:"other" %}
  {% radioinput label:"Piano" value:"piano" %}
  {% radioinput value:"guitar" %}
  {% radioinput value:"other" %}
{% endradiogroup %}

Check out our Community case for some elaborate examples.