Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix error when no model scope is set

  • Loading branch information...
commit d16a9ab98eb18f63782fa2ae8800bcdc0715eaa6 1 parent fe2f56e
@ADmad ADmad authored
View
19 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -3075,6 +3075,25 @@ public function testFormInputs() {
$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);
}
/**
View
5 lib/Cake/View/Helper/FormHelper.php
@@ -833,8 +833,11 @@ public function label($fieldName = null, $text = null, $options = array()) {
*/
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'];
Please sign in to comment.
Something went wrong with that request. Please try again.