CRM-13233, js and formRule fixes
authorkurund <kurund@civicrm.org>
Thu, 22 Aug 2013 21:20:43 +0000 (02:50 +0530)
committerkurund <kurund@civicrm.org>
Thu, 22 Aug 2013 21:20:43 +0000 (02:50 +0530)
----------------------------------------
* CRM-13233: Payment Method field (payment_processor) should not be required if total fee is $0
  http://issues.civicrm.org/jira/browse/CRM-13233

CRM/Event/Form/Registration/Register.php
templates/CRM/Event/Form/Registration/Register.tpl

index b24d9eb48e15c99c2881c2e3980ab84e9f8362c1..07237e4322c11980dab5674fd7046568f4871cfe 100644 (file)
@@ -858,7 +858,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     if ($self->_values['event']['is_monetary']) {
-      if (($fields['amount'] > 0) && empty($fields['payment_processor'])) {
+      if (($fields['amount'] > 0) && (!isset($fields['payment_processor']) && $fields['payment_processor'] != 0 )) {
         $errors['payment_processor'] = ts('Please select a Payment Method');
       }
       if (is_array($self->_paymentProcessor)) {
index 2863ba9cc197852facba5ef6622469ebc4a750a7..8e46d18dba0bf6dcb1d9902ebfc9fdcaf7ee3869 100644 (file)
         flag = 0;
       }
 
-      cj('#priceset input').change(function () {
-        if (((cj(this).attr('data-amount') == 0) || (cj('#pricevalue').text() == symbol + " 0.00" )) && flag ) {
-          cj(".payment_options-group").hide();
-          cj("div.payment_processor-section").hide();
-          cj("div#payment_information").hide();
-        }
-        else {
-          cj(".payment_options-group").show();
-          cj("div.payment_processor-section").show();
-          cj("div#payment_information").show();
-        }
-
-      });
+      if (((cj('#priceset input:checked').attr('data-amount') == 0) ||
+        (cj('#pricevalue').text() == symbol + " 0.00" )) && flag) {
+        cj(".payment_options-group").hide();
+        cj("div.payment_processor-section").hide();
+        cj("div#payment_information").hide();
+        // also unset selected payment methods
+        cj('input[name="payment_processor"]').removeProp('checked');
+      }
+      else {
+        cj(".payment_options-group").show();
+        cj("div.payment_processor-section").show();
+        cj("div#payment_information").show();
+      }
     }
+
+    cj('#priceset input').change(function () {
+      skipPaymentMethod();
+    });
+
     {/literal}
   </script>
 {/if}