diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 5427dbdfd8f..f1e4a25177d 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2851,6 +2851,34 @@ public function testInputOverridingMagicSelectType() { $this->assertTags($result, $expected); } +/** + * Test that inferred types do not override developer input + * + * @return void + */ + public function testInputMagicTypeDoesNotOverride() { + $this->View->viewVars['users'] = array('value' => 'good', 'other' => 'bad'); + $result = $this->Form->input('Model.user', array('type' => 'checkbox')); + $expected = array( + 'div' => array('class' => 'input checkbox'), + array('input' => array( + 'type' => 'hidden', + 'name' => 'data[Model][user]', + 'id' => 'ModelUser_', + 'value' => 0, + )), + array('input' => array( + 'name' => 'data[Model][user]', + 'type' => 'checkbox', + 'id' => 'ModelUser', + 'value' => 1 + )), + 'label' => array('for' => 'ModelUser'), 'User', '/label', + '/div' + ); + $this->assertTags($result, $expected); + } + /** * Test that magic input() selects are created for type=number * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index db4b4cf79cc..8a37363b7bb 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1082,7 +1082,7 @@ protected function _parseOptions($options) { $options = $this->_magicOptions($options); } - if (in_array($options['type'], array('checkbox', 'radio', 'select'))) { + if (in_array($options['type'], array('radio', 'select'))) { $options = $this->_optionsOptions($options); }