Skip to content
This repository
Browse code

closes #6413, scaffoldFields not working with add/edit methods

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8214 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 8971aad8bf87528dec994b627e0cb57de59ad6f7 1 parent 9e143bc
authored July 03, 2009
2  cake/libs/view/scaffolds/edit.ctp
@@ -25,7 +25,7 @@
25 25
 <div class="<?php echo $pluralVar;?> form">
26 26
 <?php
27 27
 	echo $form->create();
28  
-	echo $form->inputs(null, array('created', 'modified', 'updated'));
  28
+	echo $form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
29 29
 	echo $form->end(__('Submit', true));
30 30
 ?>
31 31
 </div>
63  cake/tests/cases/libs/controller/scaffold.test.php
@@ -48,6 +48,37 @@ class ScaffoldMockController extends Controller {
48 48
 	var $scaffold;
49 49
 }
50 50
 /**
  51
+ * ScaffoldMockControllerWithFields class
  52
+ *
  53
+ * @package       cake
  54
+ * @subpackage    cake.tests.cases.libs.controller
  55
+ */
  56
+class ScaffoldMockControllerWithFields extends Controller {
  57
+/**
  58
+ * name property
  59
+ *
  60
+ * @var string 'ScaffoldMock'
  61
+ * @access public
  62
+ */
  63
+	var $name = 'ScaffoldMock';
  64
+/**
  65
+ * scaffold property
  66
+ *
  67
+ * @var mixed
  68
+ * @access public
  69
+ */
  70
+	var $scaffold;
  71
+/**
  72
+ * function _beforeScaffold
  73
+ *
  74
+ * @param string method
  75
+ */
  76
+	function _beforeScaffold($method) {
  77
+		$this->set('scaffoldFields', array('title'));
  78
+		return true;
  79
+	}
  80
+}
  81
+/**
51 82
  * TestScaffoldMock class
52 83
  *
53 84
  * @package       cake
@@ -619,5 +650,37 @@ function testScaffoldVariableSetting() {
619 650
 		$this->assertEqual($result['pluralVar'], 'scaffoldMock');
620 651
 		$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
621 652
 	}
  653
+/**
  654
+ * test that the proper names and variable values are set by Scaffold
  655
+ *
  656
+ * @return void
  657
+ **/
  658
+	function testEditScaffoldWithScaffoldFields() {
  659
+		$this->Controller = new ScaffoldMockControllerWithFields();
  660
+		$this->Controller->action = 'edit';
  661
+		$this->Controller->here = '/scaffold_mock';
  662
+		$this->Controller->webroot = '/';
  663
+		$params = array(
  664
+			'plugin' => null,
  665
+			'pass' => array(1),
  666
+			'form' => array(),
  667
+			'named' => array(),
  668
+			'url' => array('url' =>'scaffold_mock'),
  669
+			'controller' => 'scaffold_mock',
  670
+			'action' => 'edit',
  671
+		);
  672
+		//set router.
  673
+		Router::reload();
  674
+		Router::setRequestInfo(array($params, array('base' => '/', 'here' => '/scaffold_mock', 'webroot' => '/')));
  675
+		$this->Controller->params = $params;
  676
+		$this->Controller->controller = 'scaffold_mock';
  677
+		$this->Controller->base = '/';
  678
+		$this->Controller->constructClasses();
  679
+		ob_start();
  680
+		new Scaffold($this->Controller, $params);
  681
+		$result = ob_get_clean();
  682
+
  683
+		$this->assertNoPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
  684
+	}
622 685
 }
623 686
 ?>

0 notes on commit 8971aad

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