Back to Joomla project (class list)

Class Select - list of methods

Utility class for creating HTML select lists
Package: Joomla\CMS\HTML\Helpers
Copyright: (C) 2007 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/HTML/Helpers/Select.php
Project: Joomla

Method Summary

public static string
(mixed $name, mixed $attribs = array(), mixed $selected = null, mixed $yes = 'JYES', mixed $no = 'JNO', mixed $id = false)

Generates a yes/no radio list.
Parameters
  • string $name The value of the HTML name attribute
  • array $attribs Additional HTML attributes for the `<select>` tag
  • string $selected The key that is selected
  • string $yes Language key for Yes
  • string $no Language key for no
  • mixed $id The id for the field or false for no id
Returns
  • string HTML for the radio list
Since
  • 1.5
-
  • \Joomla\CMS\Form\Field\RadioField
Show source code of this method: booleanlist Source Code

public static string
(mixed $data, mixed $name, mixed $attribs = null, mixed $optKey = 'value', mixed $optText = 'text', mixed $selected = null, mixed $idtag = false, mixed $translate = false)

Generates an HTML selection list.
Parameters
  • array $data An array of objects, arrays, or scalars.
  • string $name The value of the HTML name attribute.
  • mixed $attribs 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: Format options, see {@see \Joomla\CMS\HTML\HTMLHelper:: $formatOptions }. Selection options, see {@see \Joomla\CMS\HTML\Helpers\JHtmlSelect::options()}. list.attr, string|array: Additional attributes for the select element. id, string: Value to use as the select element id attribute. Defaults to the same as the name. list.select, string|array: Identifies one or more option elements to be selected, based on the option key values.
  • string $optKey The name of the object variable for the option value. If set to null, the index of the value array is used.
  • string $optText The name of the object variable for the option text.
  • mixed $selected The key that is selected (accepts an array or a string).
  • mixed $idtag Value of the field id or null by default
  • bool $translate True to translate
Returns
  • string HTML for the select list.
Since
  • 1.5
Show source code of this method: genericlist Source Code

public static string
(mixed $data, mixed $name, mixed $options = array())

Generates a grouped HTML selection list from nested arrays.
Parameters
  • array $data An array of groups, each of which is an array of options.
  • string $name The value of the HTML name attribute
  • array $options Options, an array of key/value pairs. Valid options are: Format options, {@see \Joomla\CMS\HTML\HTMLHelper:: $formatOptions }. Selection options. See {@see \Joomla\CMS\HTML\Helpers\JHtmlSelect::options()}. group.id: The property in each group to use as the group id attribute. Defaults to none. group.label: The property in each group to use as the group label. Defaults to "text". If set to null, the data array index key is used. group.items: The property in each group to use as the array of items in the group. Defaults to "items". If set to null, group.id and group. label are forced to null and the data element is assumed to be a list of selections. id: Value to use as the select element id attribute. Defaults to the same as the name. list.attr: Attributes for the select element. Can be a string or an array of key/value pairs. Defaults to none. list.select: either the value of one selected option or an array of selected options. Default: none. list.translate: Boolean. If set, text and labels are translated via Text::_().
Returns
  • string HTML for the select list
Since
  • 1.5
-
  • \RuntimeException If a group has contents that cannot be processed.
Show source code of this method: groupedlist Source Code

public static string
(mixed $start, mixed $end, mixed $inc, mixed $name, mixed $attribs = null, mixed $selected = null, mixed $format = '')

Generates a selection list of integers.
Parameters
  • int $start The start integer
  • int $end The end integer
  • int $inc The increment
  • string $name The value of the HTML name attribute
  • mixed $attribs 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.
  • mixed $selected The key that is selected
  • string $format The printf format to be applied to the number
Returns
  • string HTML for the select list
Since
  • 1.5
Show source code of this method: integerlist Source Code

public static \stdClass
(mixed $value, mixed $text = '', mixed $optKey = 'value', mixed $optText = 'text', mixed $disable = false)

Create an object that represents an option in an option list.
Parameters
  • string $value The value of the option
  • string $text The text for the option
  • mixed $optKey If a string, the returned object property name for the value. If an array, options. Valid options are: attr: String|array. Additional attributes for this option. Defaults to none. disable: Boolean. If set, this option is disabled. label: String. The value for the option label. option.attr: The property in each option array to use for additional selection attributes. Defaults to none. option.disable: The property that will hold the disabled state. Defaults to "disable". option.key: The property that will hold the selection value. Defaults to "value". option.label: The property in each option array to use as the selection label attribute. If a "label" option is provided, defaults to "label", if no label is given, defaults to null (none). option.text: The property that will hold the the displayed text. Defaults to "text". If set to null, the option array is assumed to be a list of displayable scalars.
  • string $optText The property that will hold the the displayed text. This parameter is ignored if an options array is passed.
  • bool $disable Not used.
Returns
  • \stdClass
Since
  • 1.5
Show source code of this method: option Source Code

public static string
(mixed $arr, mixed $optKey = 'value', mixed $optText = 'text', mixed $selected = null, mixed $translate = false)

Generates the option tags for an HTML select list (with no select tag surrounding the options).
Parameters
  • array $arr An array of objects, arrays, or values.
  • mixed $optKey If a string, this is the name of the object variable for the option value. If null, the index of the array of objects is used. If an array, this is a set of options, as key/value pairs. Valid options are: -Format options, {@see \Joomla\CMS\HTML\HTMLHelper:: $formatOptions }. -groups: Boolean. If set, looks for keys with the value "<optgroup>" and synthesizes groups from them. Deprecated. Defaults true for backwards compatibility. -list.select: either the value of one selected option or an array of selected options. Default: none. -list.translate: Boolean. If set, text and labels are translated via Text::_(). Default is false. -option.id: The property in each option array to use as the selection id attribute. Defaults to none. -option.key: The property in each option array to use as the selection value. Defaults to "value". If set to null, the index of the option array is used. -option.label: The property in each option array to use as the selection label attribute. Defaults to null (none). -option.text: The property in each option array to use as the displayed text. Defaults to "text". If set to null, the option array is assumed to be a list of displayable scalars. -option.attr: The property in each option array to use for additional selection attributes. Defaults to none. -option.disable: The property that will hold the disabled state. Defaults to "disable". -option.key: The property that will hold the selection value. Defaults to "value". -option.text: The property that will hold the the displayed text. Defaults to "text". If set to null, the option array is assumed to be a list of displayable scalars.
  • string $optText The name of the object variable for the option text.
  • mixed $selected The key that is selected (accepts an array or a string)
  • bool $translate Translate the option values.
Returns
  • string HTML for the select list
Since
  • 1.5
Show source code of this method: options Source Code

public static string
(mixed $data, mixed $name, mixed $attribs = null, mixed $optKey = 'value', mixed $optText = 'text', mixed $selected = null, mixed $idtag = false, mixed $translate = false)

Generates an HTML radio list.
Parameters
  • array $data An array of objects
  • string $name The value of the HTML name attribute
  • string $attribs Additional HTML attributes for the `<select>` tag
  • mixed $optKey The key that is selected
  • string $optText The name of the object variable for the option value
  • string $selected The name of the object variable for the option text
  • bool $idtag Value of the field id or null by default
  • bool $translate True if options will be translated
Returns
  • string HTML for the select list
Since
  • 1.5
Show source code of this method: radiolist Source Code

Properties Summary

protected static array
$optionDefaults
Default values for options. Organized by option group.
Since
  • 1.5

Tags Summary

Since
1.5