Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setting of step for decimal field based on precision.

  • Loading branch information...
commit 4806d09d7e3a118fc65d98f082d8a75687339ec8 1 parent 091658a
@uzyn uzyn authored
View
2  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -1883,7 +1883,7 @@ public function testInput() {
'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);
View
7 lib/Cake/View/Helper/FormHelper.php
@@ -1160,10 +1160,13 @@ protected function _magicOptions($options) {
}
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';
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.