Skip to content
Permalink
Browse files

Making magic select not override magic hidden. Tests added.

Fixes #782
  • Loading branch information...
markstory committed Jun 4, 2010
1 parent bd6e16b commit e41e89cd2a6d7e5bd71911fab14e756648126f4c
Showing with 24 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/form.php
  2. +23 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -740,7 +740,7 @@ function input($fieldName, $options = array()) {
$options['type'] = 'hidden';
}
}
if (preg_match('/_id$/', $fieldKey)) {
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
$options['type'] = 'select';
}
@@ -2118,6 +2118,29 @@ function testInputSelectType() {
$this->assertTags($result, $expected);
}
/**
* test that input() and a non standard primary key makes a hidden input by default.
*
* @return void
*/
function testInputWithNonStandardPrimaryKeyMakesHidden() {
$this->Form->create('User');
$this->Form->fieldset = array(
'User' => array(
'fields' => array(
'model_id' => array('type' => 'integer')
),
'validates' => array(),
'key' => 'model_id'
)
);
$result = $this->Form->input('model_id');
$expected = array(
'input' => array('type' => 'hidden', 'name' => 'data[User][model_id]', 'id' => 'UserModelId'),
);
$this->assertTags($result, $expected);
}
/**
* test that overriding the magic select type widget is possible
*

0 comments on commit e41e89c

Please sign in to comment.
You can’t perform that action at this time.