[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Form/ -> DropdownElement.php (summary)

(no description)

File Size: 199 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

DropdownElement:: (8 methods):
  __construct()
  addOptGroup()
  optGroups()
  options()
  val()
  getFirstOptionKey()
  setValuesInOptGroups()
  mainElementHTML()


Class: DropdownElement  - X-Ref

Class DropdownElement

Represents a HTML select. Please not that prefilling with input data only works for single values.

__construct($name, $options, $label = '')   X-Ref

param: string $name The name of this form element
param: array $options The available options
param: string $label The label text for this element (will be autoescaped)

addOptGroup($label, $options)   X-Ref
Add an `<optgroup>` and respective options

param: string $label
param: array $options
return: OptGroup a reference to the added optgroup

optGroups($optGroups = null)   X-Ref
Set or get the optgroups of an Dropdown-Element.

optgroups have to be given as associative array
* the key being the label of the group
* the value being an array of options as defined in @param null|array $optGroups
see: OptGroup::options()
return: OptGroup[]|DropdownElement

options($options = null)   X-Ref
Get or set the options of the Dropdown

Options can be given as associative array (value => label) or as an
indexd array (label = value) or as an array of arrays. In the latter
case an element has to look as follows:
option-value => array (
'label' => option-label,
'attrs' => array (
attr-key => attr-value, ...
)
)

param: null|array $options
return: $this|array

val($value = null)   X-Ref
Get or set the current value

When setting a value that is not defined in the options, the value is ignored
and the first option's value is selected instead

param: null|string|string[] $value The value to set
return: $this|string|string[]

getFirstOptionKey()   X-Ref
Returns the first option's key

return: string

setValuesInOptGroups($values)   X-Ref
Set the value in the OptGroups, including the optgroup for the options without optgroup.

param: string[] $values The values to be set
return: string[] The values actually set

mainElementHTML()   X-Ref
Create the HTML for the select it self

return: string