Applying patch from ticket #2763, adding test for it

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5278 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
dho 2007-06-15 08:32:04 +00:00
parent c9a2da3e0c
commit d9a0aa1c69
2 changed files with 4 additions and 1 deletions

View file

@ -651,7 +651,7 @@ class FormHelper extends AppHelper {
}
$output = null;
if(isset($object) && ($options['value'] == 0 || $options['value'] == 1)) {
if(isset($object) && isset($options['value']) && ($options['value'] == 0 || $options['value'] == 1)) {
$db =& ConnectionManager::getDataSource($object->useDbConfig);
$value = $db->boolean($options['value']);
$options['value'] = 1;

View file

@ -831,6 +831,9 @@ class FormHelperTest extends CakeTestCase {
$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" />');
$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->Form->validationErrors['Model']['field'] = 1;
$this->Form->data['Contact']['published'] = 1;
$result = $this->Form->checkbox('Contact.published', array('id'=>'theID'));