mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge pull request #2744 from wnasich/fix_html5_attribute_step
Rendering a proper value for html5 attribute 'step'
This commit is contained in:
commit
0906dec3c4
2 changed files with 26 additions and 1 deletions
|
@ -353,6 +353,8 @@ class ValidateUser extends CakeTestModel {
|
|||
'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
||||
'balance' => array('type' => 'float', 'null' => false, 'length' => '5,2'),
|
||||
'cost_decimal' => array('type' => 'decimal', 'null' => false, 'length' => '6,3'),
|
||||
'ratio' => array('type' => 'decimal', 'null' => false, 'length' => '10,6'),
|
||||
'population' => array('type' => 'decimal', 'null' => false, 'length' => '15,0'),
|
||||
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
||||
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||
);
|
||||
|
@ -1916,6 +1918,28 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('ValidateUser.ratio');
|
||||
$expected = array(
|
||||
'div' => array('class'),
|
||||
'label' => array('for'),
|
||||
'Ratio',
|
||||
'/label',
|
||||
'input' => array('name', 'type' => 'number', 'step' => '0.000001', 'id'),
|
||||
'/div',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('ValidateUser.population');
|
||||
$expected = array(
|
||||
'div' => array('class'),
|
||||
'label' => array('for'),
|
||||
'Population',
|
||||
'/label',
|
||||
'input' => array('name', 'type' => 'number', 'step' => '1', 'id'),
|
||||
'/div',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.email', array('id' => 'custom'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input email'),
|
||||
|
|
|
@ -1173,7 +1173,8 @@ class FormHelper extends AppHelper {
|
|||
!isset($options['step'])
|
||||
) {
|
||||
if ($type === 'decimal') {
|
||||
$options['step'] = pow(10, -1 * substr($fieldDef['length'], strpos($fieldDef['length'], ',') + 1));
|
||||
$decimalPlaces = substr($fieldDef['length'], strpos($fieldDef['length'], ',') + 1);
|
||||
$options['step'] = sprintf('%.' . $decimalPlaces . 'F', pow(10, -1 * $decimalPlaces));
|
||||
} elseif ($type === 'float') {
|
||||
$options['step'] = 'any';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue