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 ) );
148 foreach ( explode(
',', $msg ) as $option ) {
150 if ( strpos( $option,
':' ) ===
false ) {
151 $option =
"$option:$option";
154 list( $label, $value ) = explode(
':', $option );
155 $options[ trim( $label ) ] = trim( $value );
Class for generating HTML <select> or <datalist> elements.
static parseOptionsMessage(string $msg)
Parse labels and values out of a comma- and colon-separated list of options, such as is used for expi...
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 )