Difference between revisions of "List form field type"

From Joomla! Documentation

(Created page for form field type)
 
(Updated contents)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Image:Params.list.jpg|right]]
 
[[Image:Params.list.jpg|right]]
  
{{Ambox|type=notice|text=In Joomla! 1.5, [[Form field|form fields]] were [[Parameter|parameters]]. For that version, you may want to use the corresponding [[List parameter type]].}}
+
<noinclude>{{Ambox|type=notice|text=In Joomla! 1.5, [[Form field|form fields]] were [[Parameter|parameters]]. For that version, you may want to use the corresponding [[List parameter type]].}}</noinclude>
 
+
The '''list''' form field type provides a drop down list or a list box of custom-defined entries. 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.  
The '''list''' form field type provides a drop down list of custom-defined entries. 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.  
 
  
 
* '''type''' (mandatory) must be ''list''.
 
* '''type''' (mandatory) must be ''list''.
Line 10: Line 9:
 
* '''default''' (optional) is the default list item value.
 
* '''default''' (optional) is the default list 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.
 
* '''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)  is a CSS class name for the HTML form field. If omitted this will default to 'inputbox'.
+
* '''class''' (optional)  is a CSS class name for the HTML form field. If omitted this will default to 'inputbox'.
 +
* '''multiple''' (optional) is whether multiple items can be selected at the same time (''true'' or ''false'').
  
The XML <code><field></code> element must include one or more <code><option></code> elements which define the list items. The text between the <code><option></code> and <code></option></code> tags is what will be shown in the drop down list and is a translatable string. The <code><option></code> tag takes the following argument:
+
The XML <code><field></code> element must include one or more <code><option></code> elements which define the list items. The text between the <code><option></code> and <code></option></code> tags is what will be shown in the drop down list and is a translatable string. The <code><option></code> tag takes the following argument:
  
* '''value''' (mandatory) is the value that will be saved for the parameter if this item is selected.
+
* '''value''' (mandatory) is the value that will be saved for the field if this item is selected.
  
Tip: Don't forget to close the parameter definition with <code></field></code>.
+
Tip: Don't forget to close the field definition with <code></field></code>.
  
 
Example XML field definition:
 
Example XML field definition:

Revision as of 10:04, 21 May 2011

Params.list.jpg

The list form field type provides a drop down list or a list box of custom-defined entries. 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.

  • type (mandatory) must be list.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • default (optional) is the default list 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) is a CSS class name for the HTML form field. If omitted this will default to 'inputbox'.
  • multiple (optional) is whether multiple items can be selected at the same time (true or false).

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) is the value that will be saved for the field if this item is selected.

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

Example XML field definition:

<field name="mylistvalue" type="list" default="" label="Select an option" description="">
  <option value="0">Option 1</option>
  <option value="1">Option 2</option>
</field>

See also[edit]