From 91319bbe7bc665befc67a5d2e6db6490354819fb Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 8 May 2013 01:43:27 +0530 Subject: [PATCH] Fix disabled attribute check. Fixes #3818 --- .../Test/Case/View/Helper/FormHelperTest.php | 22 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index cb2349909f2..3f6e2645894 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2205,6 +2205,28 @@ public function testInputCheckbox() { '/div' ); $this->assertTags($result, $expected); + + $result = $this->Form->input('User.disabled', array( + 'label' => 'Disabled', + 'type' => 'checkbox', + 'data-foo' => 'disabled' + )); + $expected = array( + 'div' => array('class' => 'input checkbox'), + 'input' => array('type' => 'hidden', 'name' => 'data[User][disabled]', 'value' => '0', 'id' => 'UserDisabled_'), + array('input' => array( + 'type' => 'checkbox', + 'name' => 'data[User][disabled]', + 'value' => '1', + 'id' => 'UserDisabled', + 'data-foo' => 'disabled' + )), + 'label' => array('for' => 'UserDisabled'), + 'Disabled', + '/label', + '/div' + ); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 7e98cc0d491..ad331a8d76a 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2809,7 +2809,7 @@ protected function _initInputField($field, $options = array()) { } $disabledIndex = array_search('disabled', $options, true); - if ($disabledIndex !== false) { + if (is_int($disabledIndex)) { unset($options[$disabledIndex]); $options['disabled'] = true; }