Hello,
I m trying to validate video_file_file2. I need it to be a valid url only when it is not empty. Now it returns the error message even when it is empty.
So if I click in the input field, it returns the error, and when I click away, without writing anything, the error persists. Shouldn’t it validate when I click away because I left it empty?
['video_file_file2', 'each', 'rule' => ['url', 'defaultScheme' => 'http'],
'when' => function($model) {
return $model->video_file_file2 !== NULL;
}, 'whenClient' => "function(attribute, value) {
return $('input[name='Vod[video_file_file2][]']').val() !== '';
}", 'message' => 'look'
],