FormHelper::checkbox() now sets name of hidden field when name option is set. Closes #5224

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7449 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-08-09 22:08:17 +00:00
parent 3a06f840c3
commit a180071f6c
2 changed files with 8 additions and 1 deletions

View file

@ -823,7 +823,7 @@ class FormHelper extends AppHelper {
$value = $db->boolean($options['value'], false);
$options['value'] = 1;
}
$output = $this->hidden($fieldName, array('value' => '0', 'id' => $options['id'] . '_'), true);
$output = $this->hidden($fieldName, array('name' => $options['name'], 'value' => '0', 'id' => $options['id'] . '_'), true);
if (isset($options['value']) && $value == $options['value']) {
$options['checked'] = 'checked';

View file

@ -2426,6 +2426,13 @@ class FormHelperTest extends CakeTestCase {
array('input' => array('type' => 'checkbox', 'name' => 'data[CustomField][1][value]', 'value' => '1', 'id' => 'CustomField1Value'))
);
$this->assertTags($result, $expected);
$result = $this->Form->checkbox('Test.test', array('name' => 'myField'));
$expected = array(
'input' => array('type' => 'hidden', 'name' => 'myField', 'value' => '0', 'id' => 'TestTest_'),
array('input' => array('type' => 'checkbox', 'name' => 'myField', 'value' => '1', 'id' => 'TestTest'))
);
$this->assertTags($result, $expected);
}
/**
* testDateTime method