mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fix input type inference when type=>checkbox
FormHelper should not infer types when the explicit type is checkbox. Instead the provided type should be used. Fixes #2491
This commit is contained in:
parent
81d14e4f1a
commit
30e139412d
2 changed files with 29 additions and 1 deletions
|
@ -2851,6 +2851,34 @@ class FormHelperTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
|
@ -1082,7 +1082,7 @@ class FormHelper extends AppHelper {
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue