Yii2 Difference of when and whenClient

2019-08-04 08:53发布

问题:

['size', 'required','when' => function($model) {
        return ($model->color == 'RED') ? true : false;
    },
    'whenClient' => "function() {
        if($('#provider').val() == 'RED') {
            return true;
        } else {
            return false;
        }
    }"]

I wonder if I still need to put the whenClient code? My validation still working without submitting the form by using only when.

标签: php yii2