Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / htmlform / HTMLTextField.php
index 157116d..4d5bcab 100644 (file)
@@ -15,14 +15,14 @@ class HTMLTextField extends HTMLFormField {
        }
 
        function getInputHTML( $value ) {
-               $attribs = array(
+               $attribs = [
                                'id' => $this->mID,
                                'name' => $this->mName,
                                'size' => $this->getSize(),
                                'value' => $value,
                                'dir' => $this->mDir,
                                'spellcheck' => $this->getSpellCheck(),
-                       ) + $this->getTooltipAndAccessKey();
+                       ] + $this->getTooltipAndAccessKey() + $this->getDataAttribs();
 
                if ( $this->mClass !== '' ) {
                        $attribs['class'] = $this->mClass;
@@ -30,7 +30,7 @@ class HTMLTextField extends HTMLFormField {
 
                # @todo Enforce pattern, step, required, readonly on the server side as
                # well
-               $allowedParams = array(
+               $allowedParams = [
                        'type',
                        'min',
                        'max',
@@ -46,7 +46,7 @@ class HTMLTextField extends HTMLFormField {
                        'autofocus',
                        'multiple',
                        'readonly'
-               );
+               ];
 
                $attribs += $this->getAttributes( $allowedParams );
 
@@ -88,12 +88,12 @@ class HTMLTextField extends HTMLFormField {
                $attribs = $this->getTooltipAndAccessKey();
 
                if ( $this->mClass !== '' ) {
-                       $attribs['classes'] = array( $this->mClass );
+                       $attribs['classes'] = [ $this->mClass ];
                }
 
                # @todo Enforce pattern, step, required, readonly on the server side as
                # well
-               $allowedParams = array(
+               $allowedParams = [
                        'autofocus',
                        'autosize',
                        'disabled',
@@ -105,25 +105,32 @@ class HTMLTextField extends HTMLFormField {
                        'required',
                        'tabindex',
                        'type',
-               );
+               ];
 
-               $attribs += $this->getAttributes( $allowedParams, array(
-                       'maxlength' => 'maxLength',
-                       'readonly' => 'readOnly',
-                       'tabindex' => 'tabIndex',
-               ) );
+               $attribs += OOUI\Element::configFromHtmlAttributes(
+                       $this->getAttributes( $allowedParams )
+               );
 
                $type = $this->getType( $attribs );
 
-               return $this->getInputWidget( array(
+               return $this->getInputWidget( [
                        'id' => $this->mID,
                        'name' => $this->mName,
                        'value' => $value,
                        'type' => $type,
-               ) + $attribs );
+               ] + $attribs );
        }
 
        protected function getInputWidget( $params ) {
                return new OOUI\TextInputWidget( $params );
        }
+
+       /**
+        * Returns an array of data-* attributes to add to the field.
+        *
+        * @return array
+        */
+       protected function getDataAttribs() {
+               return [];
+       }
 }