mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1082 from ADmad/bugfix-3560
Don't set "required" attribute for checkboxes (unless explicitly specifi...
This commit is contained in:
commit
a03cbddf76
2 changed files with 25 additions and 1 deletions
|
@ -128,6 +128,7 @@ class Contact extends CakeTestModel {
|
|||
'rule_on_create' => array('rule' => array('maxLength', 50), 'on' => 'create'),
|
||||
'rule_on_update' => array('rule' => array('between', 1, 50), 'on' => 'update'),
|
||||
),
|
||||
'boolean_field' => array('rule' => 'boolean')
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -7279,6 +7280,28 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.boolean_field', array('type' => 'checkbox'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input checkbox required'),
|
||||
array('input' => array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'data[Contact][boolean_field]',
|
||||
'id' => 'ContactBooleanField_',
|
||||
'value' => '0'
|
||||
)),
|
||||
array('input' => array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'data[Contact][boolean_field]',
|
||||
'value' => '1',
|
||||
'id' => 'ContactBooleanField'
|
||||
)),
|
||||
'label' => array('for' => 'ContactBooleanField'),
|
||||
'Boolean Field',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1379,9 +1379,10 @@ class FormHelper extends AppHelper {
|
|||
unset($options['default']);
|
||||
}
|
||||
|
||||
$options += array('required' => false);
|
||||
$options = $this->_initInputField($fieldName, $options) + array('hiddenField' => true);
|
||||
$value = current($this->value($valueOptions));
|
||||
$output = "";
|
||||
$output = '';
|
||||
|
||||
if (empty($options['value'])) {
|
||||
$options['value'] = 1;
|
||||
|
|
Loading…
Reference in a new issue