Hello!
I found a solution, set the relations in the plugin controller:
public function initialize()
{
$this->Schools->addAssociations([
'belongsTo' => [
'Countries' => ['className' =>
'App\Model\Table\CountriesTable'],
'Languages' => ['className' => 'App\Model\Table\LanguagesTable']
]
]);
}
I hope that helps and I appreciate another better solution.
Cheers!
El viernes, 12 de junio de 2015, 12:53:53 (UTC+2), [email protected]
escribió:
>
> Hi to all,
>
> I need to use themes (for admin section) in my new CakePHP 3 app. Themes
> now require create a plugin. Ok, I did it and works. But I have a problem.
> Inside the plugin I have controllers (for admin methods) but the models
> (Tables) related still outside the plugin (app/src/Model/Table) because
> they are shared between admin controllers and public controllers.
>
> When I try to do something like:
>
> // app/plugins/Root/src/Controller/SchoolController.php
>
> public function index()
> {
> $this->paginate = [
> 'contain' => ['Countries', 'Languages']
> ];
> $this->set('schools', $this->paginate($this->Schools));
> $this->set('_serialize', ['schools']);
> }
>
> I have the next error message:
>
> *Schools is not associated with Countries*Without pagination, all works
> fine:
>
> // app/plugins/Root/src/Controller/SchoolController.php
>
> public function index()
> {
> $this->set('schools', $this->paginate($this->Schools));
> $this->set('_serialize', ['schools']);
> }
>
> Anothers methods like Add, Edit that use another Tables (to create html
> selectors inputs) in adition of School Table doen't work.
>
> The question is, Is possible to use an external model (table) call it from
> plugin's controller? I read the doc and api without results.
>
> Thanks for advance ans sorry for my poor English.
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.