Fixing issue where get forms created with model = false would create inputs with name = ''. Tests added. Fixes #1455

This commit is contained in:
mark_story 2011-01-15 14:39:24 -05:00
parent b8780586ec
commit ca299a097c
2 changed files with 23 additions and 1 deletions

View file

@ -1960,7 +1960,7 @@ class FormHelper extends AppHelper {
}
$view = ClassRegistry::getObject('view');
$name = $view->field;
$name = !empty($view->field) ? $view->field : $view->model;
if (!empty($view->fieldSuffix)) {
$name .= '[' . $view->fieldSuffix . ']';
}

View file

@ -5729,6 +5729,28 @@ class FormHelperTest extends CakeTestCase {
)));
}
/**
* 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.
*