Reputation: 168
I make a plugin Blog with cakephp3. When I call the url /blog/edit/3, all is good, the form inputs are filled.
I have a class \Blog\Model\Table\ArticlesTable (file location: ROOT/plugins/Blog/src/Model/Table/ArticlesTable.php)
Here the class :
<?php
namespace Blog\Model\Table;
use \Cake\ORM\Table;
use \Cake\Validation\Validator;
class ArticlesTable extends Table
{
public function initialize(array $config)
{
//die('IN ArticlesTable::initialize');
$this->table('articles');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
}
public function validationDefault(Validator $validator)
{
...
}
}
In the debugar, I see the message :
Generated Models
The following Table objects used Cake\ORM\Table instead of a concrete class: Articles
But my class is not loaded
Some one has an idea about my problem ?
Thanks
Phil
Upvotes: 3
Views: 1355
Reputation: 168
I resolved the problem. You need to specify the plugin namespace while loading the model:
$this->loadModel('Namespace.TableName');
In my example I changed:
class BlogController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadModel('Articles');//<----- HERE
}
...
}
to
class BlogController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadModel('Blog.Articles'); //<----- HERE
}
...
}
Upvotes: 2
Reputation: 9614
Create the ArticlesTable
class in the src/Model/Table
folder. The easiest way to do it is using the bake command
bin/cake bake model Articles
Upvotes: 0