Fixes #16253: Fixed empty checkboxlist validation

This commit is contained in:
Nikolay
2019-01-10 17:17:37 +03:00
committed by Alexander Makarov
parent 22d30f1999
commit c59df914c1
2 changed files with 32 additions and 20 deletions

View File

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.16 under development
------------------------
- Bug #16253: Fixed empty checkboxlist validation (GHopperMSK)
- Bug #15286: Fixed incorrect formatting of time with timezone information (rugabarbo)
- Bug #17021: Fix to do not remove existing message category files in a subfolder (albertborsos)
- Bug #16991: Removed usage of `utf8_encode()` from `Request::resolvePathInfo()` (GHopperMSK)

View File

@ -325,7 +325,19 @@
// client-side validation
$.each(data.attributes, function () {
this.$form = $form;
if (!findInput($form, this).is(":disabled")) {
let $input = findInput($form, this);
if ($input.is(":disabled")) {
return true;
}
// pass SELECT without options
if ($input.length && $input[0].tagName.toLowerCase() === 'select') {
if (!$input[0].options.length) {
return true;
} else if (($input[0].options.length === 1) && ($input[0].options[0].value === '')) {
return true;
}
}
this.cancelled = false;
// perform validation only if the form is being submitted or if an attribute is pending validation
if (data.submitting || this.status === 2 || this.status === 3) {
@ -334,6 +346,7 @@
msg = [];
messages[this.id] = msg;
}
var event = $.Event(events.beforeValidateAttribute);
$form.trigger(event, [this, msg, deferreds]);
if (event.result !== false) {
@ -347,7 +360,6 @@
this.cancelled = true;
}
}
}
});
// ajax validation
@ -406,7 +418,6 @@
submitForm: function () {
var $form = $(this),
data = $form.data('yiiActiveForm');
if (data.validated) {
// Second submit's call (from validate/updateInputs)
data.submitting = false;