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

  } 

  }
4

1 に答える 1

2

前にドル記号を忘れたようですthis

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

する必要があります

if($this->Invoice->validates(array('fieldList'=>array('Relationship.partyone','Relationship.active')){
于 2012-05-27T07:04:45.153 に答える