Browse Source

Fixes #16253: Fixed empty checkboxlist validation

tags/2.0.16
Nikolay 6 years ago committed by Alexander Makarov
parent
commit
c59df914c1
  1. 1
      framework/CHANGELOG.md
  2. 51
      framework/assets/yii.activeForm.js

1
framework/CHANGELOG.md

@ -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)

51
framework/assets/yii.activeForm.js

@ -325,27 +325,39 @@
// client-side validation
$.each(data.attributes, function () {
this.$form = $form;
if (!findInput($form, this).is(":disabled")) {
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) {
var msg = messages[this.id];
if (msg === undefined) {
msg = [];
messages[this.id] = msg;
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) {
var msg = messages[this.id];
if (msg === undefined) {
msg = [];
messages[this.id] = msg;
}
var event = $.Event(events.beforeValidateAttribute);
$form.trigger(event, [this, msg, deferreds]);
if (event.result !== false) {
if (this.validate) {
this.validate(this, getValue($form, this), msg, deferreds, $form);
}
var event = $.Event(events.beforeValidateAttribute);
$form.trigger(event, [this, msg, deferreds]);
if (event.result !== false) {
if (this.validate) {
this.validate(this, getValue($form, this), msg, deferreds, $form);
}
if (this.enableAjaxValidation) {
needAjaxValidation = true;
}
} else {
this.cancelled = true;
if (this.enableAjaxValidation) {
needAjaxValidation = true;
}
} else {
this.cancelled = true;
}
}
});
@ -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;

Loading…
Cancel
Save