【发布时间】:2013-07-18 16:41:12
【问题描述】:
Declaration of UtilityBehavior::beforeDelete() should be compatible with ModelBehavior::beforeDelete(Model $model, $cascade = true)
我在加载一个控制器时收到此错误,但它在任何其他控制器中都不存在。
这是 Term 控制器中唯一的删除操作
public function admin_delete($id = null) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
}
$this->Term->id = $id;
if (!$this->Term->exists()) {
throw new NotFoundException(__('Invalid term'));
}
if ($this->Term->delete()) {
$this->Session->setFlash(__('Term deleted'));
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('term was not deleted'));
$this->redirect(array('action' => 'index'));
}
控制器是术语控制器
【问题讨论】:
-
消息告诉你问题出在哪里!您显然在您正在加载的模型中声明了
beforeDelete()(Car 或 Term 查看您的控制器代码),该模型具有与基本模型的beforeDelete()方法不同的参数。 -
@MartinBean: Term 模型文件中没有 beforeDelete(),抱歉,汽车打错了