API16:JHtmlSelect/genericlist
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Generates an HTML selection list.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
static genericlist($data, $name, $attribs=null, $optKey= 'value', $optText= 'text', $selected=null, $idtag=false, $translate=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $data | An array of objects, arrays, or scalars. | |
| $name | The value of the HTML name attribute. | |
| $attribs | null | Additional HTML attributes for the <select> tag. This can be an array of attributes, or an array of options. Treated as options if it is the last argument passed. Valid options are: |
| $optKey | 'value' | |
| $optText | 'text' | |
| $selected | null | |
| $idtag | false | |
| $translate | false |
Returns
string HTML for the select list.
Defined in
libraries/joomla/html/html/select.php
Importing
jimport( 'joomla.html.html.select' );
Source Body
public static function genericlist( $data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, $translate = false ) { // Set default options $options = array_merge( JHtml::$formatOptions, array( 'format.depth' => 0, 'id' => false, ) ); if (is_array($attribs) && func_num_args() == 3) { // Assume we have an options array $options = array_merge($options, $attribs); } else { // Get options from the parameters $options['id'] = $idtag; $options['list.attr'] = $attribs; $options['list.translate'] = $translate; $options['option.key'] = $optKey; $options['option.text'] = $optText; $options['list.select'] = $selected; } $attribs = ''; if (isset($options['list.attr'])) { if (is_array($options['list.attr'])) { $attribs = JArrayHelper::toString($options['list.attr']); } else { $attribs = $options['list.attr']; } if ($attribs != '') { $attribs = ' ' . $attribs; } } $id = $options['id'] !== false ? $options['id'] : $name; $id = str_replace(array('[', ']'), '', $id); $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); $html = $baseIndent . '<select' . ($id !== '' ? ' id="' . $id . '"' : '') . ' name="' . $name . '"' . $attribs . '>' . $options['format.eol'] . self::options($data, $options) . $baseIndent . '</select>' . $options['format.eol'] ; return $html; }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
