1

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;
    }

  } 

  }

1 Answer 1

2

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')){
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.