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 ) );
Class for generating HTML <select> or <datalist> elements.
setAttribute( $name, $value)
__construct( $name=false, $id=false, $default=false)
static formatOptions( $options, $default=false)
This accepts an array of form: label => value label => ( label => value, label => value )
addOption( $label, $value=false)
addOptions( $options)
This accepts an array of form label => value label => ( label => value, label => value )