Source for file groupedlist.php
Documentation is available at groupedlist.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Form Field class for the Joomla Platform.
* Provides a grouped list select field.
* @package Joomla.Platform
protected $type =
'GroupedList';
* Method to get the field option groups.
* @return array The field option objects as a nested array in groups.
* @throws UnexpectedValueException
foreach ($this->element->children() as $element)
switch ($element->getName())
// The element is an <option />
// Initialize the group if necessary.
if (!isset
($groups[$label]))
$groups[$label] =
array();
$disabled = (string)
$element['disabled'];
$disabled =
($disabled ==
'true' ||
$disabled ==
'disabled' ||
$disabled ==
'1');
// Create a new option object based on the <option /> element.
'select.option', ($element['value']) ? (string)
$element['value'] :
trim((string)
$element),
// Set some option attributes.
$tmp->class = (string)
$element['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string)
$element['onclick'];
$groups[$label][] =
$tmp;
// The element is a <group />
if ($groupLabel = (string)
$element['label'])
$label =
JText::_($groupLabel);
// Initialize the group if necessary.
if (!isset
($groups[$label]))
$groups[$label] =
array();
// Iterate through the children and build an array of options.
foreach ($element->children() as $option)
// Only add <option /> elements.
if ($option->getName() !=
'option')
$disabled = (string)
$option['disabled'];
$disabled =
($disabled ==
'true' ||
$disabled ==
'disabled' ||
$disabled ==
'1');
// Create a new option object based on the <option /> element.
'select.option', ($option['value']) ? (string)
$option['value'] :
JText::_(trim((string)
$option)),
JText::_(trim((string)
$option)), 'value', 'text', $disabled
// Set some option attributes.
$tmp->class = (string)
$option['class'];
// Set some JavaScript option attributes.
$tmp->onclick = (string)
$option['onclick'];
$groups[$label][] =
$tmp;
throw
new UnexpectedValueException(sprintf('Unsupported element %s in JFormFieldGroupedList', $element->getName()), 500);
* Method to get the field input markup fora grouped list.
* Multiselect is enabled by using the multiple attribute.
* @return string The field input markup.
// Initialize some field attributes.
$attr .=
!empty($this->class) ?
' class="' .
$this->class .
'"' :
'';
$attr .=
$this->disabled ?
' disabled' :
'';
$attr .=
!empty($this->size) ?
' size="' .
$this->size .
'"' :
'';
$attr .=
$this->multiple ?
' multiple' :
'';
$attr .=
$this->required ?
' required aria-required="true"' :
'';
$attr .=
$this->autofocus ?
' autofocus' :
'';
// Initialize JavaScript field attributes.
// Create a read-only list (no name) with a hidden input to store the value.
'select.groupedlist', $groups, null,
'list.attr' =>
$attr, 'id' =>
$this->id, 'list.select' =>
$this->value, 'group.items' =>
null, 'option.key.toHtml' =>
false,
'option.text.toHtml' =>
false
$html[] =
'<input type="hidden" name="' .
$this->name .
'" value="' .
$this->value .
'"/>';
// Create a regular list.
'select.groupedlist', $groups, $this->name,
'list.attr' =>
$attr, 'id' =>
$this->id, 'list.select' =>
$this->value, 'group.items' =>
null, 'option.key.toHtml' =>
false,
'option.text.toHtml' =>
false
Documentation generated on Tue, 19 Nov 2013 15:04:06 +0100 by phpDocumentor 1.4.3