Skip to content

Commit

Permalink
Fix disabled attribute check.
Browse files Browse the repository at this point in the history
Fixes #3818
  • Loading branch information
ADmad committed May 7, 2013
1 parent 3720897 commit 91319bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 91319bb

Please sign in to comment.