php - cakephp 2 $this->Model not set -
i working on cake 2.4 , if debug $this in controller, $this->model not set should.
controller: customerscontroller(.php)
model: customermodel(.php)
since naming conventions right, have no clue issue located.
relevant code:
customer.php: <?php class customer extends shop { public $validate = array(/* ... */); protected $_schema = array(/* ... */); public function beforesave($options = array()) { parent::beforesave($options); } } customerscontroller.php: <?php app::uses('shopscontroller', 'controller'); class customerscontroller extends shopscontroller { public function beforefilter() { $this->auth->allow('login'); parent::beforefilter(); } }
your model filename wrong. should "customer" without "model" suffix. way gets automatically loaded , become available $this->customer in controller.
edit: you're extending not appmodel shopmodel reason (why?), try in customer model:
public $name = 'customer'; public $usetable = 'customers'; cakephp not merge/update properties when inherit controllers or models.
Comments
Post a Comment