CakePHP not binding model automatically

时间:2016-04-25 09:16:21

标签: php cakephp

CakePHP 2.8.3 is not binding the model automatically.

Model :

<?php
class Item extends AppModel
{

    public $name = 'Item';

    public $belongsTo = array(

        'Cat' => array(
            'className'  => 'Cat',
            'foreignKey' => 'cat_id',
        ),

    );

}

The above Model is not working.

However when I Bind Model in controller. It works fine.

$this->Item->bindModel(array(
            'belongsTo' => array(
            'Cat' => array(
            'foreignKey' => 'cat_id',
            ))));

What could be the cause ?

0 个答案:

没有答案