73 $this->attributes[$name] = $value;
81 return $this->attributes[$name] ??
null;
88 public function addOption( $label, $value =
false ) {
89 $value = $value !==
false ? $value : $label;
90 $this->options[] = [ $label => $value ];
116 foreach (
$options as $label => $value ) {
117 if ( is_array( $value ) ) {
119 $data .= Html::rawElement(
'optgroup', [
'label' => $label ], $contents ) .
"\n";
125 $data .=
Xml::option( $label, $value, $selected ) .
"\n";
138 foreach ( $this->options as
$options ) {
142 return Html::rawElement( $this->tagName, $this->attributes, rtrim( $contents ) );
156 foreach ( explode(
',', $msg ) as $option ) {
158 if ( strpos( $option,
':' ) ===
false ) {
159 $option =
"$option:$option";
162 [ $label, $value ] = explode(
':', $option );
163 $options[ trim( $label ) ] = trim( $value );
169class_alias( XmlSelect::class,
'XmlSelect' );