mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fix error when no model scope is set
This commit is contained in:
parent
fe2f56e8bd
commit
d16a9ab98e
2 changed files with 23 additions and 1 deletions
|
@ -3075,6 +3075,25 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->Form->create('Contact');
|
||||
$result = $this->Form->inputs(null, null, array('legend' => 'Hello'));
|
||||
$this->assertTags($result, $expected);
|
||||
$this->Form->end();
|
||||
|
||||
$this->Form->create(false);
|
||||
$expected = array(
|
||||
'fieldset' => array(),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'label' => array('for' => 'foo'),
|
||||
'Foo',
|
||||
'/label',
|
||||
'input' => array('type' => 'text', 'name' => 'data[foo]', 'id' => 'foo'),
|
||||
'*/div',
|
||||
'/fieldset'
|
||||
);
|
||||
$result = $this->Form->inputs(
|
||||
array('foo' => array('type' => 'text')),
|
||||
array(),
|
||||
array('legend' => false)
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -833,8 +833,11 @@ class FormHelper extends AppHelper {
|
|||
*/
|
||||
public function inputs($fields = null, $blacklist = null, $options = array()) {
|
||||
$fieldset = $legend = true;
|
||||
$modelFields = array();
|
||||
$model = $this->model();
|
||||
$modelFields = array_keys($this->_introspectModel($model, 'fields'));
|
||||
if ($model) {
|
||||
$modelFields = array_keys($this->_introspectModel($model, 'fields'));
|
||||
}
|
||||
if (is_array($fields)) {
|
||||
if (array_key_exists('legend', $fields) && !in_array('legend', $modelFields)) {
|
||||
$legend = $fields['legend'];
|
||||
|
|
Loading…
Add table
Reference in a new issue