MediaWiki  1.34.0
SelectWithInputWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
5 use OOUI\DropdownInputWidget;
6 use OOUI\TextInputWidget;
7 
14 class 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  ],
41  $config
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 }
MediaWiki\Widget\SelectWithInputWidget
Select and input widget.
Definition: SelectWithInputWidget.php:14
MediaWiki\Widget\SelectWithInputWidget\$config
array $config
Definition: SelectWithInputWidget.php:16
MediaWiki\Widget\SelectWithInputWidget\$textinput
TextInputWidget $textinput
Definition: SelectWithInputWidget.php:18
MediaWiki\Widget\SelectWithInputWidget\getJavaScriptClassName
getJavaScriptClassName()
Definition: SelectWithInputWidget.php:65
MediaWiki\Widget\SelectWithInputWidget\$dropdowninput
DropdownInputWidget $dropdowninput
Definition: SelectWithInputWidget.php:20
MediaWiki\Widget
Definition: CheckMatrixWidget.php:3
MediaWiki\Widget\SelectWithInputWidget\getConfig
getConfig(&$config)
Definition: SelectWithInputWidget.php:69
MediaWiki\Widget\SelectWithInputWidget\__construct
__construct(array $config=[])
A version of the SelectWithInputWidget, with or set to true.
Definition: SelectWithInputWidget.php:32