Skip to content
This repository
Browse code

Fix error when no model scope is set

  • Loading branch information...
commit d16a9ab98eb18f63782fa2ae8800bcdc0715eaa6 1 parent fe2f56e
ADmad authored December 20, 2012
19  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -3075,6 +3075,25 @@ public function testFormInputs() {
3075 3075
 		$this->Form->create('Contact');
3076 3076
 		$result = $this->Form->inputs(null, null, array('legend' => 'Hello'));
3077 3077
 		$this->assertTags($result, $expected);
  3078
+		$this->Form->end();
  3079
+
  3080
+		$this->Form->create(false);
  3081
+		$expected = array(
  3082
+			'fieldset' => array(),
  3083
+			array('div' => array('class' => 'input text')),
  3084
+			'label' => array('for' => 'foo'),
  3085
+			'Foo',
  3086
+			'/label',
  3087
+			'input' => array('type' => 'text', 'name' => 'data[foo]', 'id' => 'foo'),
  3088
+			'*/div',
  3089
+			'/fieldset'
  3090
+		);
  3091
+		$result = $this->Form->inputs(
  3092
+			array('foo' => array('type' => 'text')),
  3093
+			array(),
  3094
+			array('legend' => false)
  3095
+		);
  3096
+		$this->assertTags($result, $expected);
3078 3097
 	}
3079 3098
 
3080 3099
 /**
5  lib/Cake/View/Helper/FormHelper.php
@@ -833,8 +833,11 @@ public function label($fieldName = null, $text = null, $options = array()) {
833 833
  */
834 834
 	public function inputs($fields = null, $blacklist = null, $options = array()) {
835 835
 		$fieldset = $legend = true;
  836
+		$modelFields = array();
836 837
 		$model = $this->model();
837  
-		$modelFields = array_keys($this->_introspectModel($model, 'fields'));
  838
+		if ($model) {
  839
+			$modelFields = array_keys($this->_introspectModel($model, 'fields'));
  840
+		}
838 841
 		if (is_array($fields)) {
839 842
 			if (array_key_exists('legend', $fields) && !in_array('legend', $modelFields)) {
840 843
 				$legend = $fields['legend'];

0 notes on commit d16a9ab

Please sign in to comment.
Something went wrong with that request. Please try again.