From: Prateek Saxena Date: Wed, 25 Jul 2018 05:29:03 +0000 (+0530) Subject: SelectWithInput: Add 'disabled' property on main widget X-Git-Tag: 1.34.0-rc.0~4650^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=820a18762fa9999760b21bf6dcb67fb3c0af9f77;p=lhc%2Fweb%2Fwiklou.git SelectWithInput: Add 'disabled' property on main widget …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 --- diff --git a/includes/htmlform/fields/HTMLSelectAndOtherField.php b/includes/htmlform/fields/HTMLSelectAndOtherField.php index a4d9bca67b..4e64e9d7cb 100644 --- a/includes/htmlform/fields/HTMLSelectAndOtherField.php +++ b/includes/htmlform/fields/HTMLSelectAndOtherField.php @@ -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, diff --git a/includes/htmlform/fields/HTMLSelectOrOtherField.php b/includes/htmlform/fields/HTMLSelectOrOtherField.php index 91050a0cc6..47c1f18fae 100644 --- a/includes/htmlform/fields/HTMLSelectOrOtherField.php +++ b/includes/htmlform/fields/HTMLSelectOrOtherField.php @@ -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, diff --git a/includes/widget/SelectWithInputWidget.php b/includes/widget/SelectWithInputWidget.php index 5ceed4c408..262903dd39 100644 --- a/includes/widget/SelectWithInputWidget.php +++ b/includes/widget/SelectWithInputWidget.php @@ -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