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 parent
::__construct( $config );
42 $this->config
= $config;
43 $this->textinput
= new TextInputWidget( $config['textinput'] );
44 $this->dropdowninput
= new DropdownInputWidget( $config['dropdowninput'] );
48 ->addClasses( [ 'mw-widget-selectWithInputWidget' ] )
49 ->appendContent( $this->dropdowninput
, $this->textinput
);
52 protected function getJavaScriptClassName() {
53 return 'mw.widgets.SelectWithInputWidget';
56 public function getConfig( &$config ) {
57 $config['textinput'] = $this->config
['textinput'];
58 $config['dropdowninput'] = $this->config
['dropdowninput'];
59 $config['dropdowninput']['dropdown']['$overlay'] = true;
60 $config['or'] = $this->config
['or'];
61 return parent
::getConfig( $config );