MediaWiki REL1_37
SelectWithInputWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use OOUI\DropdownInputWidget;
6use OOUI\TextInputWidget;
7
14class SelectWithInputWidget extends \OOUI\Widget {
16 protected $config;
18 protected $textinput;
20 protected $dropdowninput;
21
32 public function __construct( array $config = [] ) {
33 // Configuration initialization
34 $config = array_merge(
35 [
36 'textinput' => [],
37 'dropdowninput' => [],
38 'or' => false,
39 'required' => false,
40 ],
42 );
43
44 if ( isset( $config['disabled'] ) && $config['disabled'] ) {
45 $config['textinput']['disabled'] = true;
46 $config['dropdowninput']['disabled'] = true;
47 }
48
49 $config['textinput']['required'] = $config['or'] ? false : $config['required'];
50 $config['dropdowninput']['required'] = $config['required'];
51
52 parent::__construct( $config );
53
54 // Properties
55 $this->config = $config;
56 $this->textinput = new TextInputWidget( $config['textinput'] );
57 $this->dropdowninput = new DropdownInputWidget( $config['dropdowninput'] );
58
59 // Initialization
60 $this
61 ->addClasses( [ 'mw-widget-selectWithInputWidget' ] )
62 ->appendContent( $this->dropdowninput, $this->textinput );
63 }
64
65 protected function getJavaScriptClassName() {
66 return 'mw.widgets.SelectWithInputWidget';
67 }
68
69 public function getConfig( &$config ) {
70 $config['textinput'] = $this->config['textinput'];
71 $config['dropdowninput'] = $this->config['dropdowninput'];
72 $config['dropdowninput']['dropdown']['$overlay'] = true;
73 $config['or'] = $this->config['or'];
74 $config['required'] = $this->config['required'];
75 return parent::getConfig( $config );
76 }
77}
__construct(array $config=[])
A version of the SelectWithInputWidget, with or set to true.