mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 20:19:42 +08:00
beforeSubmit function after global validation all fields forms
This commit is contained in:
@ -127,6 +127,13 @@
|
|||||||
var $form = $(this),
|
var $form = $(this),
|
||||||
data = $form.data('yiiActiveForm');
|
data = $form.data('yiiActiveForm');
|
||||||
if (data.validated) {
|
if (data.validated) {
|
||||||
|
if (data.settings.beforeSubmit !== undefined) {
|
||||||
|
if (data.settings.beforeSubmit($form) == false) {
|
||||||
|
data.validated = false;
|
||||||
|
data.submitting = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// continue submitting the form since validation passes
|
// continue submitting the form since validation passes
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -135,7 +142,6 @@
|
|||||||
clearTimeout(data.settings.timer);
|
clearTimeout(data.settings.timer);
|
||||||
}
|
}
|
||||||
data.submitting = true;
|
data.submitting = true;
|
||||||
if (!data.settings.beforeSubmit || data.settings.beforeSubmit($form)) {
|
|
||||||
validate($form, function (messages) {
|
validate($form, function (messages) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
$.each(data.attributes, function () {
|
$.each(data.attributes, function () {
|
||||||
@ -166,9 +172,6 @@
|
|||||||
}, function () {
|
}, function () {
|
||||||
data.submitting = false;
|
data.submitting = false;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
data.submitting = false;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user