这是产生错误的 add.ctp 文件
<?php
echo $form->create('Category');
echo $form->input('name');
echo $form->end('Save Post');
?>
这是与 add.ctp 关联的 CategoriesController.php 文件
<?php
class CategoriesController extends AppController {
var $name = 'Categories';
function index() {
$this->set('categories', $this->Category->find('all'));
}
function add() {
if (!empty($this->data)) {
if ($this->Category->save($this->data)) {
$this->Session->setFlash('Your category has been saved.');
$this->redirect(array('action' => 'index'));
}
}
}
}
?>
我不断收到以下错误消息:
Call to a member function create() on a non-object