HTMLSelectAndOtherField/HTMLSelectOrOtherField: Change how ID is handled in OOUI...
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 25 Sep 2017 18:49:51 +0000 (20:49 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 25 Sep 2017 18:50:34 +0000 (20:50 +0200)
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
includes/htmlform/fields/HTMLSelectOrOtherField.php

index 38b487a..910a053 100644 (file)
@@ -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,
index a009b28..f6c0b07 100644 (file)
@@ -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,