From d93d746663a4755d6ca00ea9b93942de04f3a8f2 Mon Sep 17 00:00:00 2001 From: phpnut Date: Wed, 20 Jun 2007 04:30:45 +0000 Subject: [PATCH] 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 --- cake/libs/view/helpers/form.php | 2 +- cake/tests/cases/libs/view/helpers/form.test.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index aed1a358e..1fec29b03 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -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'; diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 53ac2edda..da3d529c2 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -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, ''); + $this->assertEqual($result, ''); $this->Form->data['Model']['field'] = ''; $result = $this->Form->checkbox('Model.field', array('id'=>'theID', 'value' => 'myvalue')); - $this->assertEqual($result, ''); + $this->assertEqual($result, ''); $this->Form->validationErrors['Model']['field'] = 0; $result = $this->Form->checkbox('Model.field', array('value' => 'myvalue')); - $this->assertEqual($result, ''); + $this->assertEqual($result, ''); $result = $this->Form->checkbox('Contact.field', array('value' => 'myvalue')); - $this->assertEqual($result, ''); - + $this->assertEqual($result, ''); + + $result = $this->Form->checkbox('Model.field'); + $this->assertEqual($result, ''); + $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 { } } -?> \ No newline at end of file +?>