Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakePHP: how set error validation to input field manually in controller

I want set error validation to input field manually in controller example:

  if ($remainTime < 30) {
      ..... set error validation in here (error: limitTime ), ( error is not in model )
  }

other question: i want to ask : bindModel ( in this case , I use bindModel in Behaviors ) 'll cause loss of relationship with other model but is bindModel cause loss of $var validate,too ?

like image 857
meotimdihia Avatar asked Aug 28 '10 07:08

meotimdihia


1 Answers

if the $validate is defined in the model, bindModel wont cause closs of $var validate.

As for you primary question; you can set/unset/update $validationErrors of the models..eg

($remainTime < 30) {
   $this->Model->validationErrors['limitTime'] = "time is less than 30";
}
like image 60
sharmil Avatar answered Oct 28 '22 08:10

sharmil