Yii2: Conditional Validator always returns required

前端 未结 5 1466
-上瘾入骨i
-上瘾入骨i 2021-02-07 17:24

I am trying to use Yii2\'s conditional validator as given in the guide like:

Model code

public function rules()
{
   // $discharged = function($model) {          


        
5条回答
  •  时光说笑
    2021-02-07 18:02

    i had the similar requirement i solved it using the following code

    ['discharge_date', 'required', 'whenClient' => function($model) {
            return $model->discharged == 1;
     }, 'enableClientValidation' => false]
    

提交回复
热议问题