Go to the documentation of this file.
65 $this->attributes[$name] = $value;
73 return $this->attributes[$name] ??
null;
80 public function addOption( $label, $value =
false ) {
81 $value = $value !==
false ? $value : $label;
82 $this->options[] = [ $label => $value ];
108 foreach (
$options as $label => $value ) {
109 if ( is_array( $value ) ) {
111 $data .=
Html::rawElement(
'optgroup', [
'label' => $label ], $contents ) .
"\n";
117 $data .=
Xml::option( $label, $value, $selected ) .
"\n";
130 foreach ( $this->options as
$options ) {
134 return Html::rawElement( $this->tagName, $this->attributes, rtrim( $contents ) );
__construct( $name=false, $id=false, $default=false)
setAttribute( $name, $value)
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Class for generating HTML <select> or <datalist> elements.
addOptions( $options)
This accepts an array of form label => value label => ( label => value, label => value )
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
addOption( $label, $value=false)
static formatOptions( $options, $default=false)
This accepts an array of form: label => value label => ( label => value, label => value )