diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index a3c39aeeb..f8712b409 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1883,7 +1883,7 @@ class FormHelperTest extends CakeTestCase { 'label' => array('for'), 'Cost Decimal', '/label', - 'input' => array('name', 'type' => 'number', 'id'), + 'input' => array('name', 'type' => 'number', 'step' => '0.001', 'id'), '/div', ); $this->assertTags($result, $expected); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 11f2fc070..f7f2fbb63 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1160,10 +1160,13 @@ class FormHelper extends AppHelper { } if ( $options['type'] === 'number' && - $type === 'float' && !isset($options['step']) ) { - $options['step'] = 'any'; + if ($type === 'decimal') { + $options['step'] = pow(10, -1 * substr($fieldDef['length'], strpos($fieldDef['length'], ',') + 1)); + } elseif ($type === 'float') { + $options['step'] = 'any'; + } } }