mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Setting of step for decimal field based on precision.
This commit is contained in:
parent
091658a752
commit
4806d09d7e
2 changed files with 6 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue