From 820a18762fa9999760b21bf6dcb67fb3c0af9f77 Mon Sep 17 00:00:00 2001 From: Prateek Saxena Date: Wed, 25 Jul 2018 10:59:03 +0530 Subject: [PATCH] SelectWithInput: Add 'disabled' property on main widget MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …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 | 6 ++++++ includes/htmlform/fields/HTMLSelectOrOtherField.php | 6 ++++++ includes/widget/SelectWithInputWidget.php | 5 +++++ 3 files changed, 17 insertions(+) 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 -- 2.20.1