Actions

API15

JHTMLSelect/genericlist

From Joomla! Documentation

< API15:JHTMLSelect
Replacement filing cabinet.png
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 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

<CodeExamplesForm />