3 namespace MediaWiki\Widget
;
5 use OOUI\DropdownInputWidget
;
6 use OOUI\TextInputWidget
;
9 * Select and input widget.
11 * @copyright 2011-2017 MediaWiki Widgets Team and others; see AUTHORS.txt
14 class SelectWithInputWidget
extends \OOUI\Widget
{
16 protected $textinput = null;
17 protected $dropdowninput = null;
20 * A version of the SelectWithInputWidget, with `or` set to true.
22 * @param array $config Configuration options
23 * - array $config['textinput'] Configuration for the TextInputWidget
24 * - array $config['dropdowninput'] Configuration for the DropdownInputWidget
25 * - bool $config['or'] Configuration for whether the widget is dropdown AND input
26 * or dropdown OR input
28 public function __construct( array $config = [] ) {
29 // Configuration initialization
30 $config = array_merge(
33 'dropdowninput' => [],
39 if ( isset( $config['disabled'] ) && $config['disabled'] == true ) {
40 $config['textinput']['disabled'] = true;
41 $config['dropdowninput']['disabled'] = true;
44 parent
::__construct( $config );
47 $this->config
= $config;
48 $this->textinput
= new TextInputWidget( $config['textinput'] );
49 $this->dropdowninput
= new DropdownInputWidget( $config['dropdowninput'] );
53 ->addClasses( [ 'mw-widget-selectWithInputWidget' ] )
54 ->appendContent( $this->dropdowninput
, $this->textinput
);
57 protected function getJavaScriptClassName() {
58 return 'mw.widgets.SelectWithInputWidget';
61 public function getConfig( &$config ) {
62 $config['textinput'] = $this->config
['textinput'];
63 $config['dropdowninput'] = $this->config
['dropdowninput'];
64 $config['dropdowninput']['dropdown']['$overlay'] = true;
65 $config['or'] = $this->config
['or'];
66 return parent
::getConfig( $config );