diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 3f9a765cb..0a4e8f004 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -763,6 +763,32 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * Tests correct generation of decimal fields as text inputs + * + * @return void + */ + public function testTextFieldGenerationForDecimalAsText() { + $this->Form->create('ValidateUser'); + $result = $this->Form->input('cost_decimal', array( + 'type' => 'text' + )); + $expected = array( + 'div' => array('class' => 'input text'), + 'label' => array('for' => 'ValidateUserCostDecimal'), + 'Cost Decimal', + '/label', + array('input' => array( + 'type' => 'text', + 'name' => 'data[ValidateUser][cost_decimal]', + 'id' => 'ValidateUserCostDecimal', + 'maxlength' => 6, + )), + '/div' + ); + $this->assertTags($result, $expected); + } + /** * Tests correct generation of number fields for integer fields * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index ed614e830..21e86e93d 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1292,7 +1292,7 @@ class FormHelper extends AppHelper { if ($autoLength && in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search')) ) { - $options['maxlength'] = $fieldDef['length']; + $options['maxlength'] = (int)$fieldDef['length']; } return $options; }