API15

JHTMLSelect/genericlist

From Joomla! Documentation

< API15:JHTMLSelect
Revision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Generates an HTML select list <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</n...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Generates an HTML select list

[Edit Descripton]

Template:Description:JHTMLSelect/genericlist

Syntax[edit]

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[edit]

string HTML for the select list

Defined in[edit]

libraries/joomla/html/html/select.php

Importing[edit]

jimport( 'joomla.html.html.select' );

Source Body[edit]

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;
}

[Edit See Also] Template:SeeAlso:JHTMLSelect/genericlist

Examples[edit]

<CodeExamplesForm />