From b69f7cd247acd300078378d8eeeda26fd95860cd Mon Sep 17 00:00:00 2001 From: kurund Date: Fri, 23 Aug 2013 02:50:43 +0530 Subject: [PATCH] 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 --- CRM/Event/Form/Registration/Register.php | 2 +- .../CRM/Event/Form/Registration/Register.tpl | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) 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} -- 2.25.1