mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-30 18:17:00 +08:00
Skip validation if file input does not exist (#13977)
This commit is contained in:
committed by
Alexander Makarov
parent
0f0e895475
commit
46c50e43c4
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.16 under development
|
||||
------------------------
|
||||
|
||||
- Bug #13977: Skip validation if file input does not exist (RobinKamps, s1lver)
|
||||
- Bug #16183: Fixed when `yii\helpers\BaseFileHelper` sometimes returned wrong value (samdark, SilverFire, OndrejVasicek)
|
||||
- Bug #13932: Fix number validator attributes comparison (uaoleg, s1lver)
|
||||
- Bug #14039, #16636: Fixed validation for disabled inputs (s1lver, omzy83)
|
||||
|
||||
@ -376,13 +376,15 @@ yii.validation = (function ($) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Continue validation if file input does not exist
|
||||
var fileInput = $(attribute.input, attribute.$form).get(0);
|
||||
|
||||
// Skip validation if file input does not exist
|
||||
// (in case file inputs are added dynamically and no file input has been added to the form)
|
||||
if (typeof $(attribute.input, attribute.$form).get(0) === "undefined") {
|
||||
if (typeof fileInput === "undefined") {
|
||||
return [];
|
||||
}
|
||||
|
||||
var files = $(attribute.input, attribute.$form).get(0).files;
|
||||
var files = fileInput.files;
|
||||
if (!files) {
|
||||
messages.push(options.message);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user