[ Index ]

PHP Cross Reference of DokuWiki




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

(no description)

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

Defines 1 class

DropdownElement:: (9 methods):

Class: DropdownElement  - X-Ref

Class DropdownElement

Represents a HTML select. Please note that this does not support multiple selected options!

__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

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

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 @see OptGroup::options()

return: OptGroup[]|DropdownElement
param: null|array $optGroups

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, ...

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

attr($name, $value = null)   X-Ref
Gets or sets an attribute

When no $value is given, the current content of the attribute is returned.
An empty string is returned for unset attributes.

When a $value is given, the content is set to that value and the Element
itself is returned for easy chaining

return: string|$this
param: string $name Name of the attribute to access
param: null|string $value New value to set

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

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

getFirstOption()   X-Ref
Returns the first options as it will be rendered in HTML

return: string

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

return: bool
param: string $value

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

return: string