Joomla groupedlist Form Field Type

The groupedlist form field type provides a drop down list which has the ability to show grouped data.

XML Field Definition

<field name="mylist" type="groupedlist" label="Select option">
<group label="Group 1">
<option value="0">Option 1</option>
<option value="1">Option 2</option>
</group>
<group label="Group 2">
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</group>
<option value="5">Option 5</option>
<option value="6">Option 6</option>
</field>

Additional Parameters

multiple: Set to true so that multiple items can be selected at the same time (true or false).

The <option> Element

The XML <field> element must include one or more <option> elements which define the list items. The text between the <option> and </option> tags is what will be shown in the drop down list and is a translatable string. The <option> tag takes the following argument:

value (mandatory): It is the value that will be saved for the field if this item is selected.

The <group> Element

To group the data simply put a <group> before the <option> elements you want to group and a </group> after them. The <group> tag takes the following argument:

label (translatable): It is the text shown in the list. Don't forget to close the field definition with </field>.