Joomla radio Form Field Type
The radio form field type provides radio buttons to select different options. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.
This field is mainly used in configuration with Yes/No and Show/Hide options.
XML Field Definition
<field name="myradiovalue"
type="radio"
default="0"
label="Select an option">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
Mandatory Parameters
- type must be radio.
- name is the unique name of the field.
- label (translatable) is the descriptive title of the field.
Optional Parameters
- default is the default radio button item value.
- description (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.
- layout determines how the field on the form is displayed.
Layouts
There are two layouts available:
- layout="joomla.form.field.radio.switcher"
- layout="joomla.form.field.radio.buttons" (Default)
Examples
1. Site Offline Field (Global Configuration)
<field
name="offline"
type="radio"
label="COM_CONFIG_FIELD_SITE_OFFLINE_LABEL"
layout="joomla.form.field.radio.switcher"
default="0"
filter="boolean">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
2. Featured Field (com_content)
<field
name="featured"
type="radio"
label="JFEATURED"
layout="joomla.form.field.radio.switcher"
default="0">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>