diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index b836cb2b7..b63bf5f65 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -185,9 +185,11 @@ class Scaffold extends Object { $associations = $this->__associations(); $this->controller->set(compact('modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar', - 'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations')); + 'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations')); - $this->controller->view = 'scaffold'; + if ($this->controller->view && $this->controller->view !== 'Theme') { + $this->controller->view = 'scaffold'; + } $this->__scaffold($params); } /** @@ -365,21 +367,7 @@ class Scaffold extends Object { * @access private */ function __scaffoldError() { - $pathToViewFile = ''; - - if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS. 'scaffold.error.ctp')) { - $pathToViewFile = APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.error.ctp'; - } elseif (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS. 'scaffold.error.thtml')) { - $pathToViewFile = APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.error.thtml'; - } elseif (file_exists(APP . 'views' . DS . 'scaffolds' . DS . 'scaffold.error.ctp')) { - $pathToViewFile = APP . 'views' . DS . 'scaffolds' . DS . 'scaffold.error.ctp'; - } elseif (file_exists(APP . 'views' . DS . 'scaffolds' . DS . 'scaffold.error.thtml')) { - $pathToViewFile = APP . 'views' . DS . 'scaffolds' . DS . 'scaffold.error.thtml'; - } else { - $pathToViewFile = LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . 'scaffold_error.ctp'; - } - - return $this->controller->render($this->action, $this->layout, $pathToViewFile); + return $this->controller->render('error', $this->layout); } /** * When methods are now present in a controller @@ -520,6 +508,10 @@ class ScaffoldView extends ThemeView { } } + if ($name === 'scaffolds' . DS . $subDir . 'error') { + return LIBS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; + } + return $this->_missingView($paths[0] . $name . $this->ext, 'missingView'); } } diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index da859b7ca..f595025e6 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -50,7 +50,7 @@ class TestScaffoldView extends ScaffoldView { * @package cake.tests * @subpackage cake.tests.cases.libs.controller */ -class ScaffoldTest extends CakeTestCase { +class ScaffoldViewTest extends CakeTestCase { var $fixtures = array('core.post'); @@ -67,6 +67,11 @@ class ScaffoldTest extends CakeTestCase { $result = $ScaffoldView->testGetFilename('index'); $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp'; $this->assertEqual($result, $expected); + + + $result = $ScaffoldView->testGetFilename('error'); + $expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; + $this->assertEqual($result, $expected); } } ?> \ No newline at end of file