mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for Ticket #2795, fixes hidden field for checkbox.
Updated FormHelperTest::testCheckboxField() to reflect the correct return value git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5310 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
b9f56fb0a7
commit
d93d746663
2 changed files with 10 additions and 7 deletions
|
@ -655,8 +655,8 @@ class FormHelper extends AppHelper {
|
|||
$db =& ConnectionManager::getDataSource($object->useDbConfig);
|
||||
$value = $db->boolean($options['value']);
|
||||
$options['value'] = 1;
|
||||
$output = $this->hidden($fieldName, array('value' => '0', 'id' => $options['id'] . '_'), true);
|
||||
}
|
||||
$output = $this->hidden($fieldName, array('value' => '0', 'id' => $options['id'] . '_'), true);
|
||||
|
||||
if(isset($options['value']) && $value == $options['value']) {
|
||||
$options['checked'] = 'checked';
|
||||
|
|
|
@ -821,19 +821,22 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->Form->validationErrors['Model']['field'] = 1;
|
||||
$this->Form->data['Model']['field'] = 'myvalue';
|
||||
$result = $this->Form->checkbox('Model.field', array('id'=>'theID', 'value' => 'myvalue'));
|
||||
$this->assertEqual($result, '<input type="checkbox" name="data[Model][field]" type="checkbox" id="theID" value="myvalue" class="form-error" checked="checked" />');
|
||||
$this->assertEqual($result, '<input type="hidden" name="data[Model][field]" value="0" id="theID_" class="form-error" /><input type="checkbox" name="data[Model][field]" type="checkbox" id="theID" value="myvalue" class="form-error" checked="checked" />');
|
||||
|
||||
$this->Form->data['Model']['field'] = '';
|
||||
$result = $this->Form->checkbox('Model.field', array('id'=>'theID', 'value' => 'myvalue'));
|
||||
$this->assertEqual($result, '<input type="checkbox" name="data[Model][field]" type="checkbox" id="theID" value="myvalue" class="form-error" />');
|
||||
$this->assertEqual($result, '<input type="hidden" name="data[Model][field]" value="0" id="theID_" class="form-error" /><input type="checkbox" name="data[Model][field]" type="checkbox" id="theID" value="myvalue" class="form-error" />');
|
||||
|
||||
$this->Form->validationErrors['Model']['field'] = 0;
|
||||
$result = $this->Form->checkbox('Model.field', array('value' => 'myvalue'));
|
||||
$this->assertEqual($result, '<input type="checkbox" name="data[Model][field]" type="checkbox" value="myvalue" id="ModelField" />');
|
||||
$this->assertEqual($result, '<input type="hidden" name="data[Model][field]" value="0" id="ModelField_" /><input type="checkbox" name="data[Model][field]" type="checkbox" value="myvalue" id="ModelField" />');
|
||||
|
||||
$result = $this->Form->checkbox('Contact.field', array('value' => 'myvalue'));
|
||||
$this->assertEqual($result, '<input type="checkbox" name="data[Contact][field]" type="checkbox" value="myvalue" id="ContactField" />');
|
||||
|
||||
$this->assertEqual($result, '<input type="hidden" name="data[Contact][field]" value="0" id="ContactField_" /><input type="checkbox" name="data[Contact][field]" type="checkbox" value="myvalue" id="ContactField" />');
|
||||
|
||||
$result = $this->Form->checkbox('Model.field');
|
||||
$this->assertEqual($result, '<input type="hidden" name="data[Model][field]" value="0" id="ModelField_" /><input type="checkbox" name="data[Model][field]" type="checkbox" value="1" id="ModelField" />');
|
||||
|
||||
$this->Form->validationErrors['Model']['field'] = 1;
|
||||
$this->Form->data['Contact']['published'] = 1;
|
||||
$result = $this->Form->checkbox('Contact.published', array('id'=>'theID'));
|
||||
|
@ -851,4 +854,4 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue