Skip to content

Commit 548cccb

Browse files
committed
"maxlength" is not a valid attribute for input element of type "number" in html5.
1 parent b210849 commit 548cccb

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/Cake/Test/Case/View/Helper/FormHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public function testTextFieldGenerationForFloats() {
748748
'type' => 'float',
749749
'null' => false,
750750
'default' => null,
751-
'length' => null
751+
'length' => 10
752752
)));
753753

754754
$this->Form->create('Contact');
@@ -1841,7 +1841,7 @@ public function testInput() {
18411841
'label' => array('for'),
18421842
'Balance',
18431843
'/label',
1844-
'input' => array('name', 'type' => 'number', 'maxlength' => 8, 'id'),
1844+
'input' => array('name', 'type' => 'number', 'id'),
18451845
'/div',
18461846
);
18471847
$this->assertTags($result, $expected);

lib/Cake/View/Helper/FormHelper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,13 +1242,10 @@ protected function _maxLength($options) {
12421242
$options['type'] !== 'select'
12431243
);
12441244
if ($autoLength &&
1245-
in_array($options['type'], array('text', 'email', 'tel', 'url'))
1245+
in_array($options['type'], array('text', 'email', 'tel', 'url', 'search'))
12461246
) {
12471247
$options['maxlength'] = $fieldDef['length'];
12481248
}
1249-
if ($autoLength && $fieldDef['type'] === 'float') {
1250-
$options['maxlength'] = array_sum(explode(',', $fieldDef['length'])) + 1;
1251-
}
12521249
return $options;
12531250
}
12541251

0 commit comments

Comments
 (0)