Skip to content

Commit

Permalink
Fixing issue where get forms created with model = false would create …
Browse files Browse the repository at this point in the history
…inputs with name = ''. Tests added. Fixes #1455
  • Loading branch information
markstory committed Jan 15, 2011
1 parent b878058 commit ca299a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -1960,7 +1960,7 @@ function _name($options = array(), $field = null, $key = 'name') {
}

$view = ClassRegistry::getObject('view');
$name = $view->field;
$name = !empty($view->field) ? $view->field : $view->model;
if (!empty($view->fieldSuffix)) {
$name .= '[' . $view->fieldSuffix . ']';
}
Expand Down
22 changes: 22 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -5729,6 +5729,28 @@ function testGetFormCreate() {
)));
}

/**
* test get form, and inputs when the model param is false
*
* @return void
*/
function testGetFormWithFalseModel() {
$encoding = strtolower(Configure::read('App.encoding'));
$result = $this->Form->create(false, array('type' => 'get'));

$expected = array('form' => array(
'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add',
'accept-charset' => $encoding
));
$this->assertTags($result, $expected);

$result = $this->Form->text('reason');
$expected = array(
'input' => array('type' => 'text', 'name' => 'reason', 'id' => 'reason')
);
$this->assertTags($result, $expected);
}

/**
* test that datetime() works with GET style forms.
*
Expand Down

0 comments on commit ca299a0

Please sign in to comment.