API15:JHTMLSelect/genericlist
From Joomla! Documentation
Description
Generates an HTML select list
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
genericlist($arr, $name, $attribs=null, $key= 'value', $text= 'text', $selected=NULL, $idtag=false, $translate=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $arr | An array of objects | |
| $name | The value of the HTML name attribute | |
| $attribs | null | Additional HTML attributes for the <select> tag |
| $key | 'value' | The name of the object variable for the option value |
| $text | 'text' | The name of the object variable for the option text |
| $selected | NULL | The key that is selected (accepts an array or a string) |
| $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
function genericlist( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL, $idtag = false, $translate = false )
{
if ( is_array( $arr ) ) {
reset( $arr );
}
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id = $name;
if ( $idtag ) {
$id = $idtag;
}
$id = str_replace('[','',$id);
$id = str_replace(']','',$id);
$html = '<select name="'. $name .'" id="'. $id .'" '. $attribs .'>';
$html .= JHTMLSelect::Options( $arr, $key, $text, $selected, $translate );
$html .= '</select>';
return $html;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples