1
我是cakephp的新手,我試圖在代碼中使用$ this-> Session-> setFlash(),它表示有一個錯誤:調用一個非對象的成員函數setFlash()!這裏是我的代碼
function add(){
if(!empty($this->data)){
if($this->Post->save($this->data)){
$this->Session->setFlash('The post was successfully added');
$this->redirect(array('action'=>'index'));
}else{
$this->Session->setFlash('The post was not saved, please try again');
}
}
}
我能做些什麼來解決這個問題?