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

meotimdihia picture meotimdihia · Aug 28, 2010 · Viewed 20.3k times · Source

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 ?

Answer

sharmil picture sharmil · Nov 25, 2010

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