Merge "OOUIHTMLForm: Make boolean form field parameters actually work everywhere"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 4 Sep 2015 19:17:28 +0000 (19:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Sep 2015 19:17:28 +0000 (19:17 +0000)
includes/htmlform/HTMLFormField.php
includes/htmlform/HTMLTextAreaField.php
includes/htmlform/HTMLTextField.php

index 0fab033..13756e3 100644 (file)
@@ -920,7 +920,7 @@ abstract class HTMLFormField {
         * @return array Attributes
         */
        public function getAttributes( array $list, array $mappings = null ) {
-               static $boolAttribs = array( 'disabled', 'required', 'multiple', 'readonly' );
+               static $boolAttribs = array( 'disabled', 'required', 'autofocus', 'multiple', 'readonly' );
 
                $ret = array();
                foreach ( $list as $key ) {
@@ -928,7 +928,7 @@ abstract class HTMLFormField {
 
                        if ( in_array( $key, $boolAttribs ) ) {
                                if ( !empty( $this->mParams[$key] ) ) {
-                                       $ret[$mappedKey] = '';
+                                       $ret[$mappedKey] = $mappedKey;
                                }
                        } elseif ( isset( $this->mParams[$key] ) ) {
                                $ret[$mappedKey] = $this->mParams[$key];
index 5cfea63..aeb4b7c 100644 (file)
@@ -71,11 +71,6 @@ class HTMLTextAreaField extends HTMLFormField {
                        'readonly' => 'readOnly',
                ) );
 
-               if ( isset( $attribs['readOnly'] ) ) {
-                       // this needs to be set to a boolean value - hack??
-                       $attribs['readOnly'] = true;
-               }
-
                return new OOUI\TextInputWidget( array(
                        'id' => $this->mID,
                        'name' => $this->mName,
index 40cff47..157116d 100644 (file)
@@ -113,11 +113,6 @@ class HTMLTextField extends HTMLFormField {
                        'tabindex' => 'tabIndex',
                ) );
 
-               if ( isset( $attribs['readOnly'] ) ) {
-                       // This needs to be set to a boolean value
-                       $attribs['readOnly'] = true;
-               }
-
                $type = $this->getType( $attribs );
 
                return $this->getInputWidget( array(