From 4d7b6e77bdb2a495e32c187ce2dc8d6a97df6764 Mon Sep 17 00:00:00 2001 From: mainframe98 Date: Thu, 6 Sep 2018 14:21:46 +0200 Subject: [PATCH] Use NumberInputWidget in HTMLFloatField The PHP variant of this widget was introduced in 0.27.0. Using NumberInputWidget has the advantage that HTMLFloatField and HTMLIntField can now be infused as a JavaScript NumberInputWidget. Bug: T203656 Change-Id: I5d6a913de38d12a21c9bfb1ce9790574d98a5a1b --- includes/htmlform/fields/HTMLFloatField.php | 4 ++++ includes/htmlform/fields/HTMLTextField.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/includes/htmlform/fields/HTMLFloatField.php b/includes/htmlform/fields/HTMLFloatField.php index 72381f0161..15426fdb95 100644 --- a/includes/htmlform/fields/HTMLFloatField.php +++ b/includes/htmlform/fields/HTMLFloatField.php @@ -43,4 +43,8 @@ class HTMLFloatField extends HTMLTextField { return true; } + + protected function getInputWidget( $params ) { + return new OOUI\NumberInputWidget( $params ); + } } diff --git a/includes/htmlform/fields/HTMLTextField.php b/includes/htmlform/fields/HTMLTextField.php index b51182a2da..d988c29ba1 100644 --- a/includes/htmlform/fields/HTMLTextField.php +++ b/includes/htmlform/fields/HTMLTextField.php @@ -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, -- 2.20.1