Fixing form helper checkbox hidden input generation for disabled fields. Thanks to 'trevorsg' for the patch & test case.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8173 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
jperras 2009-05-14 03:26:53 +00:00
parent 8c243ee731
commit 4f2d65943f
2 changed files with 16 additions and 1 deletions

View file

@ -853,7 +853,7 @@ class FormHelper extends AppHelper {
'id' => $options['id'] . '_', 'name' => $options['name'],
'value' => '0', 'secure' => false
);
if (isset($options['disabled'])) {
if (isset($options['disabled']) && $options['disabled'] == true) {
$hiddenOptions['disabled'] = 'disabled';
}
$output = $this->hidden($fieldName, $hiddenOptions);

View file

@ -3165,6 +3165,21 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* Test that specifying false in the 'disabled' option will not disable either the hidden input or the checkbox input
*
* @return void
**/
function testCheckboxHiddenDisabling() {
$result = $this->Form->checkbox('Account.show_name', array('disabled' => false));
$expected = array(
array('input' => array('type' => 'hidden', 'name' => 'data[Account][show_name]', 'value' => '0', 'id' => 'AccountShowName_')),
array('input' => array('type' => 'checkbox', 'name' => 'data[Account][show_name]', 'value' => '1', 'id' => 'AccountShowName'))
);
$this->assertTags($result, $expected);
}
/**
* testDateTime method
*