Difference between revisions of "Checkbox form field type"

From Joomla! Documentation

m (Changed examples for consistency with other form field types)
m (Add information about how to set the uncheck status)
Line 5: Line 5:
 
* '''label''' (mandatory) (translatable) is the descriptive title of the field.
 
* '''label''' (mandatory) (translatable) is the descriptive title of the field.
 
* '''value''' (optional) is the default value of the checkbox. If exist the checkbox will be checked by default.
 
* '''value''' (optional) is the default value of the checkbox. If exist the checkbox will be checked by default.
 +
* '''default''' (optional) is the default value (usually 0 or 1).
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the label.
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the label.
 
* '''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'.
Line 11: Line 12:
  
 
<source lang="xml"><field name="show_title" type="checkbox" label="Show title" description="Show the title of the item" value="1" /></source>
 
<source lang="xml"><field name="show_title" type="checkbox" label="Show title" description="Show the title of the item" value="1" /></source>
 +
 +
Example XML field definition (unchecked):
 +
 +
<source lang="xml"><field name="show_title" type="checkbox" label="Show title" description="Show the title of the item" value="1" default="0" /></source>
  
 
=== See also ===
 
=== See also ===
 
* [[Standard form field types|List of standard form field types]]
 
* [[Standard form field types|List of standard form field types]]
 
[[Category:Standard form field types]]</noinclude>
 
[[Category:Standard form field types]]</noinclude>

Revision as of 11:29, 3 October 2012

The checkbox form field type provides a single checkbox. If the parameter 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 checkbox
  • name (mandatory) is the unique name of the parameter.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • value (optional) is the default value of the checkbox. If exist the checkbox will be checked by default.
  • default (optional) is the default value (usually 0 or 1).
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the label.
  • class (optional) is a CSS class name for the HTML form field. If omitted this will default to 'inputbox'.

Example XML field definition:

<field name="show_title" type="checkbox" label="Show title" description="Show the title of the item" value="1" />

Example XML field definition (unchecked):

<field name="show_title" type="checkbox" label="Show title" description="Show the title of the item" value="1" default="0" />

See also[edit]