From: kurund Date: Thu, 22 Aug 2013 21:20:43 +0000 (+0530) Subject: CRM-13233, js and formRule fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b69f7cd247acd300078378d8eeeda26fd95860cd;p=civicrm-core.git CRM-13233, js and formRule fixes ---------------------------------------- * CRM-13233: Payment Method field (payment_processor) should not be required if total fee is $0 http://issues.civicrm.org/jira/browse/CRM-13233 --- diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index b24d9eb48e..07237e4322 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -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)) { diff --git a/templates/CRM/Event/Form/Registration/Register.tpl b/templates/CRM/Event/Form/Registration/Register.tpl index 2863ba9cc1..8e46d18dba 100644 --- a/templates/CRM/Event/Form/Registration/Register.tpl +++ b/templates/CRM/Event/Form/Registration/Register.tpl @@ -212,20 +212,25 @@ 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} {/if}