Commit a4383354 by Alex-Code Committed by Qiang Xue

Attach forceValidate event to attributes

Allow attributes to have their validation triggered by a custom event. `validateAttribute` is called with `forceValidate` set to true.
parent f85e8f99
...@@ -395,7 +395,7 @@ ...@@ -395,7 +395,7 @@
var watchAttribute = function ($form, attribute) { var watchAttribute = function ($form, attribute) {
var $input = findInput($form, attribute); var $input = findInput($form, attribute);
if (attribute.validateOnChange) { if (attribute.validateOnChange) {
$input.on('change.yiiActiveForm',function () { $input.on('change.yiiActiveForm', function () {
validateAttribute($form, attribute, false); validateAttribute($form, attribute, false);
}); });
} }
...@@ -413,6 +413,9 @@ ...@@ -413,6 +413,9 @@
} }
}); });
} }
$input.on('forceValidate.yiiActiveForm', function() {
validateAttribute($form, attribute, true);
});
}; };
var unwatchAttribute = function ($form, attribute) { var unwatchAttribute = function ($form, attribute) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment