mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-01 03:26:36 +08:00 
			
		
		
		
	Fixes #5124: Added support to prevent duplicated form submission when using ActiveForm
				
					
				
			This commit is contained in:
		| @ -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 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Qiang Xue
					Qiang Xue