` element. Intended to be used within a * OO.ui.FormLayout. */ class DropdownInputWidget extends InputWidget { /** * HTML ` elements can be disabled). if ( isset( $opt[ 'disabled' ] ) && $opt[ 'disabled' ] ) { $option->setAttributes( [ 'disabled' => 'disabled' ] ); } $this->options[] = $option; } // Restore the previous value, or reset to something sensible if ( $isValueAvailable ) { // Previous value is still available $this->setValue( $value ); } else { // No longer valid, reset if ( count( $options ) ) { $this->setValue( $options[0]['data'] ); } } return $this; } public function getConfig( &$config ) { $optionsConfig = []; foreach ( $this->options as $option ) { if ( $option->getTag() !== 'optgroup' ) { $label = $option->content[0]; $data = $option->getAttribute( 'value' ); $optionConfig = [ 'data' => $data, 'label' => $label ]; } else { $optgroup = $option->getAttribute( 'label' ); $optionConfig = [ 'optgroup' => $optgroup ]; } if ( $option->getAttribute( 'disabled' ) ) { $optionConfig[ 'disabled' ] = true; } $optionsConfig[] = $optionConfig; } $config['options'] = $optionsConfig; $config['$overlay'] = true; return parent::getConfig( $config ); } }