Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
gwoo authored
View
2  cake/libs/view/scaffolds/edit.ctp
@@ -25,7 +25,7 @@
<div class="<?php echo $pluralVar;?> form">
<?php
echo $form->create();
- echo $form->inputs(null, array('created', 'modified', 'updated'));
+ echo $form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
echo $form->end(__('Submit', true));
?>
</div>
View
63 cake/tests/cases/libs/controller/scaffold.test.php
@@ -48,6 +48,37 @@ class ScaffoldMockController extends Controller {
var $scaffold;
}
/**
+ * ScaffoldMockControllerWithFields class
+ *
+ * @package cake
+ * @subpackage cake.tests.cases.libs.controller
+ */
+class ScaffoldMockControllerWithFields extends Controller {
+/**
+ * name property
+ *
+ * @var string 'ScaffoldMock'
+ * @access public
+ */
+ var $name = 'ScaffoldMock';
+/**
+ * scaffold property
+ *
+ * @var mixed
+ * @access public
+ */
+ var $scaffold;
+/**
+ * function _beforeScaffold
+ *
+ * @param string method
+ */
+ function _beforeScaffold($method) {
+ $this->set('scaffoldFields', array('title'));
+ return true;
+ }
+}
+/**
* TestScaffoldMock class
*
* @package cake
@@ -619,5 +650,37 @@ function testScaffoldVariableSetting() {
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
}
+/**
+ * test that the proper names and variable values are set by Scaffold
+ *
+ * @return void
+ **/
+ function testEditScaffoldWithScaffoldFields() {
+ $this->Controller = new ScaffoldMockControllerWithFields();
+ $this->Controller->action = 'edit';
+ $this->Controller->here = '/scaffold_mock';
+ $this->Controller->webroot = '/';
+ $params = array(
+ 'plugin' => null,
+ 'pass' => array(1),
+ 'form' => array(),
+ 'named' => array(),
+ 'url' => array('url' =>'scaffold_mock'),
+ 'controller' => 'scaffold_mock',
+ 'action' => 'edit',
+ );
+ //set router.
+ Router::reload();
+ Router::setRequestInfo(array($params, array('base' => '/', 'here' => '/scaffold_mock', 'webroot' => '/')));
+ $this->Controller->params = $params;
+ $this->Controller->controller = 'scaffold_mock';
+ $this->Controller->base = '/';
+ $this->Controller->constructClasses();
+ ob_start();
+ new Scaffold($this->Controller, $params);
+ $result = ob_get_clean();
+
+ $this->assertNoPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.