Skip to content

Commit

Permalink
Fixing issue where plugin models in $uses, would create
Browse files Browse the repository at this point in the history
incorrect forms when create() is called with no arguments.
Fixes #1841
  • Loading branch information
markstory committed Jul 23, 2011
1 parent 3589a17 commit 6fb3c72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Controller.php
Expand Up @@ -866,7 +866,7 @@ public function render($view = null, $layout = null) {
if (!empty($this->uses)) {
foreach ($this->uses as $model) {
list($plugin, $className) = pluginSplit($model);
$this->request->params['models'][$model] = compact('plugin', 'className');
$this->request->params['models'][$className] = compact('plugin', 'className');
}
} if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) {
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);
Expand Down
6 changes: 2 additions & 4 deletions lib/Cake/Test/Case/Controller/ControllerTest.php
Expand Up @@ -651,6 +651,7 @@ public function testRender() {
$Controller->view = null;

$Controller = new TestController($request, new CakeResponse());
$Controller->uses = array('ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost');
$Controller->helpers = array('Html');
$Controller->constructClasses();
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
Expand All @@ -664,15 +665,12 @@ public function testRender() {

$expectedModels = array(
'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'),
'ControllerComment' => array('plugin' => null, 'className' => 'ControllerComment'),
'ControllerComment' => array('plugin' => 'TestPlugin', 'className' => 'ControllerComment'),
'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost')
);
$this->assertEqual($expectedModels, $Controller->request->params['models']);


$Controller->ControllerComment->validationErrors = array();
ClassRegistry::flush();

App::build();
}

Expand Down

0 comments on commit 6fb3c72

Please sign in to comment.