mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing issue where get forms created with model = false would create inputs with name = ''. Tests added. Fixes #1455
This commit is contained in:
parent
b8780586ec
commit
ca299a097c
2 changed files with 23 additions and 1 deletions
|
@ -1960,7 +1960,7 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = ClassRegistry::getObject('view');
|
$view = ClassRegistry::getObject('view');
|
||||||
$name = $view->field;
|
$name = !empty($view->field) ? $view->field : $view->model;
|
||||||
if (!empty($view->fieldSuffix)) {
|
if (!empty($view->fieldSuffix)) {
|
||||||
$name .= '[' . $view->fieldSuffix . ']';
|
$name .= '[' . $view->fieldSuffix . ']';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* test that datetime() works with GET style forms.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue