Permalink
Browse files

Setting of step for decimal field based on precision.

  • Loading branch information...
uzyn committed Sep 29, 2013
1 parent 091658a commit 4806d09d7e3a118fc65d98f082d8a75687339ec8
Showing with 6 additions and 3 deletions.
  1. +1 −1 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +5 −2 lib/Cake/View/Helper/FormHelper.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);
@@ -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';
+ }
}
}

0 comments on commit 4806d09

Please sign in to comment.