Difference between revisions of "Radio form field type"

From Joomla! Documentation

(Marked this version for translation)
(Added deprecation notice and link to Joomla Manual)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
<noinclude><languages /></noinclude>
 
<noinclude><languages /></noinclude>
 +
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/radio Joomla Manual Radio Field] instead}}
 +
 
<translate><!--T:1-->
 
<translate><!--T:1-->
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.</translate>  
+
The ''radio'' form field type provides radio buttons to select 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.</translate>
 
[[Image:Params.radio.jpg|right]]
 
[[Image:Params.radio.jpg|right]]
 
<translate><!--T:2-->
 
<translate><!--T:2-->
Line 14: Line 16:
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.</translate>
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.</translate>
 
<translate><!--T:7-->
 
<translate><!--T:7-->
* '''class''' (optional) New in Joomla 3, if set to class="btn-group btn-group-yesno" will show the nice coloured buttons</translate>
+
* '''class''' (optional) New in Joomla 3, if set to class="btn-group btn-group-yesno" will show coloured buttons</translate>
  
 
<translate><!--T:8-->
 
<translate><!--T:8-->
The XML <code><field></code> element must include one or more <code><option></code> elements which define the individual radio button items. The text between the <code><option></code> and <code></option></code> tags is shown as the label for the radio button and is a translatable string. The <code><option></code> tag takes the following argument:</translate>
+
The XML ''<field>'' element must include one or more ''<option>'' elements which define the individual radio button items. The text between the ''<option>'' and ''</option>'' tags is shown as the label for the radio button and is a translatable string. The ''<option>'' tag takes the following argument:</translate>
  
 
<translate><!--T:9-->
 
<translate><!--T:9-->
Line 23: Line 25:
  
 
<translate><!--T:10-->
 
<translate><!--T:10-->
Tip: Don't forget to close the field definition with <code></field></code>.</translate>
+
Tip: Don't forget to close the field definition with ''</field>''.</translate>
  
 
<translate><!--T:11-->
 
<translate><!--T:11-->
 
Example XML field definition:</translate>
 
Example XML field definition:</translate>
<source lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="">
+
<syntaxhighlight lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="">
 
   <option value="0">1</option>
 
   <option value="0">1</option>
 
   <option value="1">2</option>
 
   <option value="1">2</option>
 
</field>
 
</field>
</source>
+
</syntaxhighlight>
  
 
<translate>
 
<translate>
Line 37: Line 39:
 
For Joomla 3+ styling with arbitrary values:
 
For Joomla 3+ styling with arbitrary values:
 
</translate>
 
</translate>
<source lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group">
+
<syntaxhighlight lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group">
 
   <option value="0">1</option>
 
   <option value="0">1</option>
 
   <option value="1">2</option>
 
   <option value="1">2</option>
 
</field>
 
</field>
</source>
+
</syntaxhighlight>
  
 
<translate>
 
<translate>
Line 47: Line 49:
 
For Joomla 3+ styling with yes/no values:
 
For Joomla 3+ styling with yes/no values:
 
</translate>
 
</translate>
<source lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group btn-group-yesno">
+
<syntaxhighlight lang="xml"><field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group btn-group-yesno">
 
   <option value="1">JYES</option>
 
   <option value="1">JYES</option>
 
   <option value="0">JNO</option>
 
   <option value="0">JNO</option>
 
</field>
 
</field>
</source>
+
</syntaxhighlight>
  
 
<translate>
 
<translate>
=== See also === <!--T:17-->
+
== See Also == <!--T:17-->
 
</translate>
 
</translate>
 
<translate>
 
<translate>

Latest revision as of 15:21, 16 July 2024

Other languages:
English • ‎Nederlands • ‎español • ‎français
Stop hand nuvola.svg.png
Warning!

This page has been superseded and is no longer maintained. Please go to Joomla Manual Radio Field instead


The radio form field type provides radio buttons to select 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.

Params.radio.jpg
  • type (mandatory) must be radio.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • default (optional) is the default radio button item value.
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.
  • class (optional) New in Joomla 3, if set to class="btn-group btn-group-yesno" will show coloured buttons

The XML <field> element must include one or more <option> elements which define the individual radio button items. The text between the <option> and </option> tags is shown as the label for the radio button and is a translatable string. The <option> tag takes the following argument:

  • value (mandatory) is the value that will be saved for the parameter if this item is selected.

Tip: Don't forget to close the field definition with </field>.

Example XML field definition:

<field name="myradiovalue" type="radio" default="0" label="Select an option" description="">
  <option value="0">1</option>
  <option value="1">2</option>
</field>

For Joomla 3+ styling with arbitrary values:

<field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group">
  <option value="0">1</option>
  <option value="1">2</option>
</field>

For Joomla 3+ styling with yes/no values:

<field name="myradiovalue" type="radio" default="0" label="Select an option" description="" class="btn-group btn-group-yesno">
  <option value="1">JYES</option>
  <option value="0">JNO</option>
</field>

See Also[edit]