Closed
Description
What steps will reproduce the problem?
- Create a form with a validation rule like for a required upload field:
['example', 'file', 'skipOnEmpty' => false],
- Set
enableClientValidation = false
in the ActiveForm. (client side validation still works as expected and will prevent reproduction of the issue) - Post the form without selecting any file.
What is the expected result?
A validation error 'Please upload a file'.
What do you get instead?
The validation passes.
Additional info
The regression is introduced by the changes to validateAttribute()
in #20167 which were released with Yii 2.0.50. It still works as expected on 2.0.49.
@bizley Since skipOnEmpty is set to false, validateOnAttribute() is called and should still handle the case where no file has been uploaded. The validation should be executed even if $minFiles
is still set to the default of 0. Previously, this happened here, but this code is not reached anymore in the given scenario:
yii2/framework/validators/FileValidator.php
Line 258 in 7c5b213
Q | A |
---|---|
Yii version | 2.0.50 |
PHP version | - |
Operating system | - |