mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06: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'),
|
'label' => array('for'),
|
||||||
'Cost Decimal',
|
'Cost Decimal',
|
||||||
'/label',
|
'/label',
|
||||||
'input' => array('name', 'type' => 'number', 'id'),
|
'input' => array('name', 'type' => 'number', 'step' => '0.001', 'id'),
|
||||||
'/div',
|
'/div',
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
|
@ -1160,12 +1160,15 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
$options['type'] === 'number' &&
|
$options['type'] === 'number' &&
|
||||||
$type === 'float' &&
|
|
||||||
!isset($options['step'])
|
!isset($options['step'])
|
||||||
) {
|
) {
|
||||||
|
if ($type === 'decimal') {
|
||||||
|
$options['step'] = pow(10, -1 * substr($fieldDef['length'], strpos($fieldDef['length'], ',') + 1));
|
||||||
|
} elseif ($type === 'float') {
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
|
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
|
||||||
$options['type'] = 'select';
|
$options['type'] = 'select';
|
||||||
|
|
Loading…
Add table
Reference in a new issue