API16

JHtmlSelect/integerlist

From Joomla! Documentation

< API16:JHtmlSelect
Revision as of 21:58, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" 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 a selection list of integers.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

static integerlist($start, $end, $inc, $name, $attribs=null, $selected=null, $format= '')
Parameter Name Default Value Description
$start The start integer
$end The end integer
$inc The increment
$name The value of the HTML name attribute
$attribs null Additional HTML attributes for the <select> tag, an array of attributes, or an array of options. Treated as options if it is the last argument passed.
$selected null The key that is selected
$format The printf format to be applied to the number

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]

public static function integerlist(
        $start, $end, $inc, $name, $attribs = null, $selected = null, $format = ''
) {
        // Set default options
        $options = array_merge(
                JHtml::$formatOptions,
                array(
                        'format.depth' => 0,
                        'option.format' => '',
                        'id' => null,
                )
        );
        if (is_array($attribs) && func_num_args() == 5) {
                // Assume we have an options array
                $options = array_merge($options, $attribs);
                // Extract the format and remove it from downstream options
                $format = $options['option.format'];
                unset($options['option.format']);
        } else {
                // Get options from the parameters
                $options['list.attr'] = $attribs;
                $options['list.select'] = $selected;
        }
        $start = intval($start);
        $end = intval($end);
        $inc = intval($inc);

        $data = array();
        for ($i = $start; $i <= $end; $i += $inc)
        {
                $data[$i] = $format ? sprintf($format, $i) : $i;
        }

        // Tell genericlist() to use array keys
        $options['option.key'] = null;

        return JHtml::_('select.genericlist', $data, $name, $options);
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />