M
M
Maxim Timofeev2015-08-17 01:13:11
Yii
Maxim Timofeev, 2015-08-17 01:13:11

When validating a photo, skipOnEmpty always displays an error, how to solve it?

There is a rule in the model

['userimg', 'image', 'extensions' => 'png,jpg', 'skipOnEmpty'=>false, 'maxSize'=>5000000, 'minSize'=>100000, 'uploadRequired'=>Yii::t('order', 'noImage')]

'skipOnEmpty' error always, even when I select a photo. I am using ajax validation. What's the matter? Or is it supposed to be like this and he checks only when he submits? So how do you validate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery, 2015-08-20
@supervaleha

[ ['file'], 'file', 'extensions' => ['zip'], 'maxSize' => 2*1024*1024, 'skipOnEmpty' => true],

This is a 100% working example from the project. You don't validate this field in other rules..? For example in required

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question