mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #5845 from cakephp/issue-5832
Don't create invalid maxlength attributes for decimal columns.
This commit is contained in:
commit
77e8110a1a
2 changed files with 27 additions and 1 deletions
|
@ -763,6 +763,32 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests correct generation of decimal fields as text inputs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTextFieldGenerationForDecimalAsText() {
|
||||
$this->Form->create('ValidateUser');
|
||||
$result = $this->Form->input('cost_decimal', array(
|
||||
'type' => 'text'
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'label' => array('for' => 'ValidateUserCostDecimal'),
|
||||
'Cost Decimal',
|
||||
'/label',
|
||||
array('input' => array(
|
||||
'type' => 'text',
|
||||
'name' => 'data[ValidateUser][cost_decimal]',
|
||||
'id' => 'ValidateUserCostDecimal',
|
||||
'maxlength' => 6,
|
||||
)),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests correct generation of number fields for integer fields
|
||||
*
|
||||
|
|
|
@ -1292,7 +1292,7 @@ class FormHelper extends AppHelper {
|
|||
if ($autoLength &&
|
||||
in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search'))
|
||||
) {
|
||||
$options['maxlength'] = $fieldDef['length'];
|
||||
$options['maxlength'] = (int)$fieldDef['length'];
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue