user1393064
user1393064

Reputation: 411

why is cakephp throwing error?

I'm trying to create a validation in the controller, to check that in the relationship table the username of the person they are sending the bill too and there name is in there with an active field before the site saves the invoice in the database

relationships table is id, partyone, partytwo, active, expirydate. The validation is throwing this error Parse error: syntax error, unexpected 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;
    }

  } 

  }

Upvotes: 1

Views: 224

Answers (1)

Mike
Mike

Reputation: 4888

It looks like you forgot the dollar sign before this.

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

should be

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

Upvotes: 2

Related Questions