JHTMLSelect::option() returns an object that represents a list option.
JHTMLSelect::genericList() returns a rendered HTML string of a form select tag
based on an array of objects and a few additional parameters.
This example shows how we can implement the JElementMenus class:
/**
* Renders a Menus Selection List
*
*/
class JElementMenus extends JElement
{
/**
* Element type
*
* @access protected
* @var string
*/
var $_name = 'Menus';
/**
* Gets an HTML rendered string of the element
*
* @param string Name of the form element
* @param string Value
* @param JSimpleXMLElement XML node in which the element is
defined
* @param string Control set name, normally params
*/
function fetchElement($name, $value, &$node, $control_name)
{
// get the CSS Style from the XML node class attribute
$class = $node->attributes('class') ? 'class="'.$node->
attributes('class').'"' : 'class="inputbox"';
Component Design
[ 98 ]
// prepare an array for the options
$groups = array();
foreach ($node->children() as $group)
{
// create new Group,