Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no "attr" for simple inputs #3299

Merged
merged 1 commit into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions inc/commondropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,8 @@ function showForm($ID, $options = []) {
} else {
echo Html::input(
$field['name'], [
'attrs' => [
'type' => 'number'
] + $params]
] + $params
);
}
break;
Expand Down
6 changes: 3 additions & 3 deletions inc/html.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<input type="%1$s" name="%2$s" %3$s />',
$type, Html::cleanInputText($fieldName), Html::parseAttributes($options));
Expand Down
9 changes: 9 additions & 0 deletions tests/units/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,5 +880,14 @@ public function testInput() {
];
$expected = '<input type="text" name="in_put" value="myval" class="a_class" data-id="12" />';
$this->string(\Html::input($name, $options))->isIdenticalTo($expected);

$options = [
'type' => 'number',
'min' => '10',
'value' => 'myval',
];
$expected = '<input type="number" name="in_put" min="10" value="myval" />';
$this->string(\Html::input($name, $options))->isIdenticalTo($expected);

}
}