diff --git a/src/Console/Templates/default/actions/controller_actions.ctp b/src/Console/Templates/default/actions/controller_actions.ctp index b373758a6af..17a42296bf6 100644 --- a/src/Console/Templates/default/actions/controller_actions.ctp +++ b/src/Console/Templates/default/actions/controller_actions.ctp @@ -14,6 +14,10 @@ * @since 1.3.0 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ +$associations = []; +foreach ($modelObj->associations()->type('BelongsTo') as $assoc) { + $associations[] = "'" . $assoc->target()->alias() . "'"; +} ?> /** @@ -22,6 +26,11 @@ * @return void */ public function index() { + + $this->paginate = [ + 'contain' => [] + ]; + $this->set('', $this->paginate($this->)); } @@ -33,7 +42,9 @@ * @return void */ public function view($id = null) { - $ = $this->->get($id); + $ = $this->->get($id, [ + 'contain' => [] + ]); $this->set('', $); } diff --git a/tests/TestCase/Console/Command/Task/ControllerTaskTest.php b/tests/TestCase/Console/Command/Task/ControllerTaskTest.php index 9f46c208634..b256b8ea50b 100644 --- a/tests/TestCase/Console/Command/Task/ControllerTaskTest.php +++ b/tests/TestCase/Console/Command/Task/ControllerTaskTest.php @@ -30,6 +30,7 @@ class BakeArticlesTable extends Table { public function initialize(array $config) { + $this->belongsTo('BakeUsers'); $this->hasMany('BakeComments'); $this->belongsToMany('BakeTags'); } diff --git a/tests/bake_compare/Controller/Actions.ctp b/tests/bake_compare/Controller/Actions.ctp index 8ae1b80543f..4bcd23fb171 100644 --- a/tests/bake_compare/Controller/Actions.ctp +++ b/tests/bake_compare/Controller/Actions.ctp @@ -5,6 +5,9 @@ * @return void */ public function index() { + $this->paginate = [ + 'contain' => ['BakeUsers'] + ]; $this->set('bakeArticles', $this->paginate($this->BakeArticles)); } @@ -16,7 +19,9 @@ * @return void */ public function view($id = null) { - $bakeArticle = $this->BakeArticles->get($id); + $bakeArticle = $this->BakeArticles->get($id, [ + 'contain' => ['BakeUsers'] + ]); $this->set('bakeArticle', $bakeArticle); } @@ -36,8 +41,9 @@ $this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); } } + $bakeUsers = $this->BakeArticles->association('BakeUsers')->find('list'); $bakeTags = $this->BakeArticles->association('BakeTags')->find('list'); - $this->set(compact('bakeTags')); + $this->set(compact('bakeUsers', 'bakeTags')); } /** @@ -58,8 +64,9 @@ $this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); } } + $bakeUsers = $this->BakeArticles->association('BakeUsers')->find('list'); $bakeTags = $this->BakeArticles->association('BakeTags')->find('list'); - $this->set(compact('bakeTags')); + $this->set(compact('bakeUsers', 'bakeTags')); } /**