SelectWithInput: Add 'disabled' property on main widget
authorPrateek Saxena <prtksxna@gmail.com>
Wed, 25 Jul 2018 05:29:03 +0000 (10:59 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Wed, 25 Jul 2018 06:32:50 +0000 (12:02 +0530)
…also HTMLSelectAndOtherField and HTMLSelectOrOtherField now
pass the 'disabled' field when creating the input widget.

The OOUI versions of these HTMLFormFields would get enabled
right after infusion even they were disabled in PHP. This
makes sure that they remain disabled.

Change-Id: Iddd8ad81731dba7bdcb599d6fe104cb259b11733

includes/htmlform/fields/HTMLSelectAndOtherField.php
includes/htmlform/fields/HTMLSelectOrOtherField.php
includes/widget/SelectWithInputWidget.php

index a4d9bca..4e64e9d 100644 (file)
@@ -119,8 +119,14 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
                        $dropdownInputAttribs['classes'] = [ $this->mClass ];
                }
 
+               $disabled = false;
+               if ( isset( $this->mParams[ 'disabled' ] ) && $this->mParams[ 'disabled' ] ) {
+                       $disabled = true;
+               }
+
                return $this->getInputWidget( [
                        'id' => $this->mID,
+                       'disabled' => $disabled,
                        'textinput' => $textAttribs,
                        'dropdowninput' => $dropdownInputAttribs,
                        'or' => false,
index 91050a0..47c1f18 100644 (file)
@@ -125,8 +125,14 @@ class HTMLSelectOrOtherField extends HTMLTextField {
                        $textAttribs['placeholder'] = $this->mPlaceholder;
                }
 
+               $disabled = false;
+               if ( isset( $this->mParams[ 'disabled' ] ) && $this->mParams[ 'disabled' ] ) {
+                       $disabled = true;
+               }
+
                return $this->getInputWidget( [
                        'id' => $this->mID,
+                       'disabled' => $disabled,
                        'textinput' => $textAttribs,
                        'dropdowninput' => $dropdownAttribs,
                        'or' => true,
index 5ceed4c..262903d 100644 (file)
@@ -36,6 +36,11 @@ class SelectWithInputWidget extends \OOUI\Widget {
                        $config
                );
 
+               if ( isset( $config['disabled'] ) && $config['disabled'] == true ) {
+                       $config['textinput']['disabled'] = true;
+                       $config['dropdowninput']['disabled'] = true;
+               }
+
                parent::__construct( $config );
 
                // Properties