From e8a0b0552d41b8adc8629cab60b462fd27376bb3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 25 Sep 2017 20:49:51 +0200 Subject: [PATCH] HTMLSelectAndOtherField/HTMLSelectOrOtherField: Change how ID is handled in OOUI mode Set the ID on the main widget (mw.widgets.SelectWithInputWidget), so that it can be infused by ID. The dropdown/textbox by themselves can't be infused individually, therefore IDs on them are pretty useless; remove those where they're not necessary. Follow-up to 8bd6605736c47259bd5f901284cbd2e639cef30c. Change-Id: If54dd48f1000e3e0f5a978428a5b622797b4f765 --- includes/htmlform/fields/HTMLSelectAndOtherField.php | 6 +++--- includes/htmlform/fields/HTMLSelectOrOtherField.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/htmlform/fields/HTMLSelectAndOtherField.php b/includes/htmlform/fields/HTMLSelectAndOtherField.php index 38b487af10..910a053065 100644 --- a/includes/htmlform/fields/HTMLSelectAndOtherField.php +++ b/includes/htmlform/fields/HTMLSelectAndOtherField.php @@ -72,11 +72,10 @@ class HTMLSelectAndOtherField extends HTMLSelectField { # TextInput $textAttribs = [ - 'id' => $this->mID . '-other', 'name' => $this->mName . '-other', 'size' => $this->getSize(), 'class' => [ 'mw-htmlform-select-and-other-field' ], - 'data-id-select' => $this->mID, + 'data-id-select' => $this->mID . '-select', 'value' => $value[2], ]; @@ -100,7 +99,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { # DropdownInput $dropdownInputAttribs = [ 'name' => $this->mName, - 'id' => $this->mID, + 'id' => $this->mID . '-select', 'options' => $this->getOptionsOOUI(), 'value' => $value[1], ]; @@ -119,6 +118,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { } return $this->getInputWidget( [ + 'id' => $this->mID, 'textinput' => $textAttribs, 'dropdowninput' => $dropdownInputAttribs, 'or' => false, diff --git a/includes/htmlform/fields/HTMLSelectOrOtherField.php b/includes/htmlform/fields/HTMLSelectOrOtherField.php index a009b287c2..f6c0b07102 100644 --- a/includes/htmlform/fields/HTMLSelectOrOtherField.php +++ b/includes/htmlform/fields/HTMLSelectOrOtherField.php @@ -85,7 +85,6 @@ class HTMLSelectOrOtherField extends HTMLTextField { # DropdownInput $dropdownAttribs = [ - 'id' => $this->mID, 'name' => $this->mName, 'options' => $this->getOptionsOOUI(), 'value' => $valInSelect ? $value : 'other', @@ -103,7 +102,6 @@ class HTMLSelectOrOtherField extends HTMLTextField { # TextInput $textAttribs = [ - 'id' => $this->mID . '-other', 'name' => $this->mName . '-other', 'size' => $this->getSize(), 'value' => $valInSelect ? '' : $value, @@ -130,6 +128,7 @@ class HTMLSelectOrOtherField extends HTMLTextField { } return $this->getInputWidget( [ + 'id' => $this->mID, 'textinput' => $textAttribs, 'dropdowninput' => $dropdownAttribs, 'or' => true, -- 2.20.1