PHP Class dokuwiki\Form\DropdownElement

Represents a HTML select. Please note that this does not support multiple selected options!
Inheritance: extends dokuwiki\Form\InputElement
Mostra file Open project: splitbrain/dokuwiki

Protected Properties

Property Type Description
$optGroups OptGroup[]

Public Methods

Method Description
__construct ( string $name, array $options, string $label = '' )
addOptGroup ( string $label, array $options ) : OptGroup Add an and respective options
attr ( string $name, null | string $value = null ) : string | $this Gets or sets an attribute
optGroups ( null | array $optGroups = null ) : OptGroup[] | DropdownElement Set or get the optgroups of an Dropdown-Element.
options ( null | array $options = null ) Get or set the options of the Dropdown
val ( null | string $value = null ) Get or set the current value

Protected Methods

Method Description
getFirstOption ( ) : string Returns the first options as it will be rendered in HTML
mainElementHTML ( ) : string Create the HTML for the select it self
setValueInOptGroups ( string $value ) : boolean Set the value in the OptGroups, including the optgroup for the options without optgroup.

Method Details

__construct() public method

public __construct ( string $name, array $options, string $label = '' )
$name string The name of this form element
$options array The available options
$label string The label text for this element (will be autoescaped)

addOptGroup() public method

Add an and respective options
public addOptGroup ( string $label, array $options ) : OptGroup
$label string
$options array
return OptGroup a reference to the added optgroup

attr() public method

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
public attr ( string $name, null | string $value = null ) : string | $this
$name string Name of the attribute to access
$value null | string New value to set
return string | $this

getFirstOption() protected method

Returns the first options as it will be rendered in HTML
protected getFirstOption ( ) : string
return string

mainElementHTML() protected method

Create the HTML for the select it self
protected mainElementHTML ( ) : string
return string

optGroups() public method

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()
public optGroups ( null | array $optGroups = null ) : OptGroup[] | DropdownElement
$optGroups null | array
return OptGroup[] | DropdownElement

options() public method

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, ... ) )
public options ( null | array $options = null )
$options null | array

setValueInOptGroups() protected method

Set the value in the OptGroups, including the optgroup for the options without optgroup.
protected setValueInOptGroups ( string $value ) : boolean
$value string
return boolean

val() public method

When setting a value that is not defined in the options, the value is ignored and the first option's value is selected instead
public val ( null | string $value = null )
$value null | string The value to set

Property Details

$optGroups protected_oe property

OptGroup[]
protected $optGroups