2012-05-27 186 views
1

我試圖在控制器中創建一個驗證,檢查在關係表中他們發送賬單的人的用戶名是否與此名稱在那裏有一個活動字段,然後網站將發票保存在數據庫爲什麼cakephp會拋出錯誤?

關係表是id, partyone, partytwo, active, expirydate。驗證拋出這個錯誤解析錯誤:語法錯誤,意想不到的T_OBJECT_OPERATOR

public function add(){ 

if($this->request->is('post')){ 
$this->Invoice->set($this->request->data); 
if(this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active')){ 
    $this->Invoice->create(); 
if ($this->Invoice->saveAll($this->request->data,array('validate'=>false))) 
{ 
    $this->Session->setFlash('The invoice has been saved'); 
} else { 
     $this->Session->setFlash('The invoice could not be saved. Please, try again.'); 
     $errors=$this->Invoice->validationErrors; 
    } 

    } 

    } 

回答

2

看起來你this之前忘了美元符號。

if(this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active')){ 

應該

if($this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active')){ 
+0

愚蠢的監督! – user1393064