Permalink
Browse files

Fixing form helper checkbox hidden input generation for disabled fiel…

…ds. 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
  • Loading branch information...
1 parent 8c243ee commit 4f2d65943f860f23f77f3f834bdebb5506eaa45a @jperras jperras committed May 14, 2009
Showing with 16 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/form.php
  2. +15 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -853,7 +853,7 @@ function checkbox($fieldName, $options = array()) {
'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);
@@ -3165,6 +3165,21 @@ function testCheckboxDisabling() {
);
$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
*

0 comments on commit 4f2d659

Please sign in to comment.