diff --git a/inc/commondropdown.class.php b/inc/commondropdown.class.php index 052d3c59caf..e00401f87c8 100644 --- a/inc/commondropdown.class.php +++ b/inc/commondropdown.class.php @@ -344,9 +344,8 @@ function showForm($ID, $options = []) { } else { echo Html::input( $field['name'], [ - 'attrs' => [ 'type' => 'number' - ] + $params] + ] + $params ); } break; diff --git a/inc/html.class.php b/inc/html.class.php index 5ced6baf323..9f902f536db 100644 --- a/inc/html.class.php +++ b/inc/html.class.php @@ -4521,9 +4521,9 @@ static function hidden($fieldName, $options = []) { **/ static function input($fieldName, $options = []) { $type = 'text'; - if (isset($options['attrs']) && isset($options['attrs']['type'])) { - $type = $options['attrs']['type']; - unset($options['attrs']['type']); + if (isset($options['type'])) { + $type = $options['type']; + unset($options['type']); } return sprintf('', $type, Html::cleanInputText($fieldName), Html::parseAttributes($options)); diff --git a/tests/units/Html.php b/tests/units/Html.php index 37e133d15b2..8aa05720e13 100644 --- a/tests/units/Html.php +++ b/tests/units/Html.php @@ -880,5 +880,14 @@ public function testInput() { ]; $expected = ''; $this->string(\Html::input($name, $options))->isIdenticalTo($expected); + + $options = [ + 'type' => 'number', + 'min' => '10', + 'value' => 'myval', + ]; + $expected = ''; + $this->string(\Html::input($name, $options))->isIdenticalTo($expected); + } }