Commit 82037bc7 by Qiang Xue

Fixes #5124: Added support to prevent duplicated form submission when using `ActiveForm`

parent ac7e3bdb
......@@ -216,6 +216,7 @@ Yii Framework 2 Change Log
- Enh #5058: Added `$pageSize` parameter to `Pagination::createUrl()` to allow creating URLs with arbitrary page sizes (cdcchen, qiangxue)
- Enh #5089: Added asset debugger panel (arturf, qiangxue)
- Enh #5117: Added `beforeFilter` and `afterFilter` JS events to `GridView` (kartik-v)
- Enh #5124: Added support to prevent duplicated form submission when using `ActiveForm` (qiangxue)
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
......
......@@ -349,11 +349,15 @@
data = $form.data('yiiActiveForm');
if (data.validated) {
if (!data.submitting) {
// form is being submitted. Do nothing to avoid duplicated form submission
return false;
}
data.submitting = false;
var event = $.Event(events.beforeSubmit);
$form.trigger(event, [$form]);
$form.trigger(event);
if (event.result === false) {
data.validated = false;
data.submitting = false;
return false;
}
return true; // continue submitting the form since validation passes
......
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