Permalink
Browse files

CActiveForm - required field was not validated if left empty (bug int…

…roduced in 1.1.9)
  • Loading branch information...
1 parent 44ec408 commit aac0b391b53ffcb44c1a693bc31d03ecad01214a mdomba committed Jan 7, 2012
Showing with 10 additions and 7 deletions.
  1. +1 −0 CHANGELOG
  2. +9 −7 framework/web/js/source/jquery.yiiactiveform.js
View
@@ -4,6 +4,7 @@
Version 1.1.10 work in progress
-------------------------------
+- Bug: Fixed the bug introduced in 1.1.9 CActiveForm required field was not validated if left empty (mdomba)
- Bug: #3070: Fixed the CACtiveForm JS error if there is no field rendered (mdomba)
- Bug: #3071: Fixed the bug that afterValidateAttribute was not called properly (mdomba)
@@ -64,15 +64,17 @@
$form.data('settings', settings);
settings.submitting = false; // whether it is waiting for ajax submission result
- var validate = function (attribute) {
- var changed = false;
+ var validate = function (attribute, forceValidate) {
+ if (forceValidate) {
+ attribute.status = 2;
+ }
$.each(settings.attributes, function () {
if (this.value !== getAFValue($form.find('#' + this.inputID))) {
this.status = 2;
- changed = true;
+ forceValidate = true;
}
});
- if (!changed) {
+ if (!forceValidate) {
return;
}
@@ -108,17 +110,17 @@
$.each(settings.attributes, function (i,attribute) {
if (this.validateOnChange) {
$form.find('#' + this.inputID).change(function () {
- validate(attribute);
+ validate(attribute, false);
}).blur(function () {
if (attribute.status !== 2 && attribute.status !== 3) {
- validate(attribute);
+ validate(attribute, !attribute.status);
}
});
}
if (this.validateOnType) {
$form.find('#' + this.inputID).keyup(function () {
if (attribute.value !== getAFValue($(attribute))) {
- validate(attribute);
+ validate(attribute, false);
}
});
}

0 comments on commit aac0b39

Please sign in to comment.