davide wrote: > I'm getting a strange behaviour using the beforeValidate() callback. The > goal is to trim the required (VALID_NOT_EMPTY) fields before passing the > the cake validation. > > It's strange 'cause it seems that if I put all correct data I get the > $this->data variable full of datas, otherwise if I leave a field that > doesn't pass the validation, in the beforeValidate() I get an empty > $this->data.
Finally I made it works. I've updated the model_php4.php library in the
validates method as following
/**
* Returns true if all fields pass validation, otherwise false.
*
* @param array $data POST data
* @return boolean True if there are no errors
*/
function validates($data = null) {
if ($data == null) {
$data = $this->data;
}else{ //I've added this line.
$this->data = $data; //I've added this line.
} //I've added this line.
$errors = $this->invalidFields($data);
return count($errors) == 0;
}
Should I have to open a ticket or did I use it in the wrong way?
Thanks and bye
Davide
signature.asc
Description: OpenPGP digital signature
