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

后端 未结 6 446
南旧
南旧 2021-01-12 00:15

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

  if ($remainTime < 30) {
      ..... set error validation in here (error: lim         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 00:42

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

提交回复
热议问题