Merge "Allow partially blocked users to tag unrelated revisions"
[lhc/web/wiklou.git] / includes / widget / SelectWithInputWidget.php
index de0e4a6..a792172 100644 (file)
@@ -12,9 +12,12 @@ use OOUI\TextInputWidget;
  * @license MIT
  */
 class SelectWithInputWidget extends \OOUI\Widget {
-
-       protected $textinput = null;
-       protected $dropdowninput = null;
+       /** @var array */
+       protected $config;
+       /** @var TextInputWidget */
+       protected $textinput;
+       /** @var DropdownInputWidget */
+       protected $dropdowninput;
 
        /**
         * A version of the SelectWithInputWidget, with `or` set to true.
@@ -24,6 +27,7 @@ class SelectWithInputWidget extends \OOUI\Widget {
         *   - array $config['dropdowninput'] Configuration for the DropdownInputWidget
         *   - bool $config['or'] Configuration for whether the widget is dropdown AND input
         *       or dropdown OR input
+        *   - bool $config['required'] Configuration for whether the widget is a required input.
         */
        public function __construct( array $config = [] ) {
                // Configuration initialization
@@ -31,7 +35,8 @@ class SelectWithInputWidget extends \OOUI\Widget {
                        [
                                'textinput' => [],
                                'dropdowninput' => [],
-                               'or' => false
+                               'or' => false,
+                               'required' => false,
                        ],
                        $config
                );
@@ -41,6 +46,9 @@ class SelectWithInputWidget extends \OOUI\Widget {
                        $config['dropdowninput']['disabled'] = true;
                }
 
+               $config['textinput']['required'] = $config['or'] ? false : $config['required'];
+               $config['dropdowninput']['required'] = $config['required'];
+
                parent::__construct( $config );
 
                // Properties
@@ -63,6 +71,7 @@ class SelectWithInputWidget extends \OOUI\Widget {
                $config['dropdowninput'] = $this->config['dropdowninput'];
                $config['dropdowninput']['dropdown']['$overlay'] = true;
                $config['or'] = $this->config['or'];
+               $config['required'] = $this->config['required'];
                return parent::getConfig( $config );
        }
 }