Merge "Use NumberInputWidget in HTMLFloatField"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 12 Sep 2018 16:08:48 +0000 (16:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 12 Sep 2018 16:08:48 +0000 (16:08 +0000)
includes/htmlform/fields/HTMLFloatField.php
includes/htmlform/fields/HTMLTextField.php

index 72381f0..15426fd 100644 (file)
@@ -43,4 +43,8 @@ class HTMLFloatField extends HTMLTextField {
 
                return true;
        }
+
+       protected function getInputWidget( $params ) {
+               return new OOUI\NumberInputWidget( $params );
+       }
 }
index b51182a..d988c29 100644 (file)
@@ -117,6 +117,7 @@ class HTMLTextField extends HTMLFormField {
                        switch ( $this->mParams['type'] ) {
                                case 'int':
                                        $type = 'number';
+                                       $attribs['step'] = 1;
                                        break;
                                case 'float':
                                        $type = 'number';
@@ -181,6 +182,9 @@ class HTMLTextField extends HTMLFormField {
                }
 
                $type = $this->getType( $attribs );
+               if ( isset( $attribs['step'] ) && $attribs['step'] === 'any' ) {
+                       $attribs['step'] = null;
+               }
 
                return $this->getInputWidget( [
                        'id' => $this->mID,