From 38f6574dcd43a6b8adcfc2f9695d5937e04517aa Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 9 Dec 2019 23:10:37 +1300 Subject: [PATCH] Fix js error on choosing membership type I'm seeing a js error when I select a membership type in the back end form. It seems I have recurProcessors assigned & they have an onChange that calls buildAutoRenew - which is non existant if the action is not 2. It seems to me that the code is simplest when functions can be relied on to exist and aree called conditionally - this makes that change, also ensuring 'something' is assigned for recurProcessors to prevent the error when it's not defined that probably let to the fn being encased in an if I can't spot any obvious regression cause & perhaps there is something in my config but this might be a regression --- CRM/Member/Form.php | 2 +- templates/CRM/Member/Form/Membership.tpl | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 8337202264..af2c065916 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -219,6 +219,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $this->addPaymentProcessorSelect(TRUE, FALSE, TRUE); CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId()); + $this->assign('recurProcessor', json_encode($this->_recurPaymentProcessors)); // Build the form for auto renew. This is displayed when in credit card mode or update mode. // The reason for showing it in update mode is not that clear. if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) { @@ -233,7 +234,6 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $autoRenewElement->freeze(); } - $this->assign('recurProcessor', json_encode($this->_recurPaymentProcessors)); $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically') diff --git a/templates/CRM/Member/Form/Membership.tpl b/templates/CRM/Member/Form/Membership.tpl index 64ef92a7fe..8dd6f42ab5 100644 --- a/templates/CRM/Member/Form/Membership.tpl +++ b/templates/CRM/Member/Form/Membership.tpl @@ -510,8 +510,8 @@ {/literal} {if $membershipMode or $action eq 2} - - buildAutoRenew( null, null, '{$membershipMode}'); + buildAutoRenew( null, null, '{$membershipMode}'); + {/if} {literal} function buildAutoRenew( membershipType, processorId, mode ) { var action = {/literal}'{$action}'{literal}; @@ -574,10 +574,6 @@ } showEmailOptions(); } - {/literal} - {/if} - - {literal} var customDataType = {/literal}{$customDataType|@json_encode}{literal}; -- 2.25.1