CRM-13397 - Contribte - Add submitOnce behavior to contribute button when confirmatio...
authorColeman Watts <coleman@civicrm.org>
Tue, 22 Oct 2013 22:17:45 +0000 (15:17 -0700)
committerColeman Watts <coleman@civicrm.org>
Tue, 22 Oct 2013 23:53:23 +0000 (16:53 -0700)
----------------------------------------
* CRM-13397: Protection against multiple submits on contributions page doesn't work when confirmation page is turned off
  http://issues.civicrm.org/jira/browse/CRM-13397

CRM/Contribute/Form/Contribution/Main.php

index 358a90de472e636c6d77f5795d0f043352496c86..898798d2ce23924e7002c4846a4f72ffb43007dc 100644 (file)
@@ -544,15 +544,17 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
     }
 
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
-      $this->addButtons(array(
-          array(
-            'type' => 'upload',
-            'name' => ts('Contribute'),
-            'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
-            'isDefault' => TRUE,
-          ),
-        )
+      $submitButton = array(
+        'type' => 'upload',
+        'name' => ts('Contribute'),
+        'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+        'isDefault' => TRUE,
       );
+      // Add submit-once behavior when confirm page disabled
+      if (empty($this->_values['is_confirm_enabled'])) {
+        $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
+      }
+      $this->addButtons(array($submitButton));
     }
 
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);