Skip to content

Commit 0f0e895

Browse files
RobinKampssamdark
authored andcommitted
Fixes #13977: Skip validation if file input does not exist
1 parent 8ac45fa commit 0f0e895

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

framework/assets/yii.validation.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ yii.validation = (function ($) {
376376
return [];
377377
}
378378

379+
// Continue validation if file input does not exist
380+
// (in case file inputs are added dynamically and no file input has been added to the form)
381+
if (typeof $(attribute.input, attribute.$form).get(0) === "undefined") {
382+
return [];
383+
}
384+
379385
var files = $(attribute.input, attribute.$form).get(0).files;
380386
if (!files) {
381387
messages.push(options.message);

0 commit comments

Comments
 (0)