cakephp validation response returning data to controller -


hi have made custom validation in model. how can access result($visitor) in controller?

model:

<?php   class visitors extends appmodel  {      var $name = 'visitors';       var $validate = array(         'xxx' => array(             'rule' => array('checkxxx'),             'message' => 'yyy.'         )     );      function checkixxx($check){         $visitor = $this->find('first', array('conditions' => $check));         return $visitor;     }  }  

?>

in controller want this:

function start() {           $this->visitors->set($this->data);               if($this->visitors->validates())          {             if($this->visitors->xxx->type == 'value') //this value $visitor array in model**           {                //do           }          } 

is possible?

updated relevant answer, apologies.

//model var myfield = 'invalid';  function myvalidation($var){   if($var === true){     // passed validation test     $this->myfield = 'valid';   }else{     $this->myfield = 'invalid';   } }  // controller $this->model->set($this->data); $this->model->validates($this->data);  if($this->model->myfield == 'valid'){   // field has passed validation } 

you want use

$this->model->invalidfields() 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -