From 095cec7b24d445d85da6250607d5002485c243e3 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 26 Jan 2023 00:35:48 +0000 Subject: [PATCH] [REF][PHP8.2] Fix Dynamic property payment instrument id on back office contribution form --- CRM/Contribute/Form/AbstractEditPayment.php | 2 +- CRM/Contribute/Form/Contribution.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 1aa0ee72f4..59c30d96ac 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -707,7 +707,7 @@ WHERE contribution_id = {$id} * * @throws \CRM_Core_Exception */ - protected function getDefaultPaymentInstrumentId() { + protected function getDefaultPaymentInstrumentId(): int { $paymentInstrumentID = CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer'); return (int) ($paymentInstrumentID ?? $this->_paymentProcessor['payment_instrument_id']); } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index daac2892e9..4a137b44c0 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -208,6 +208,14 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ protected $previousContributionStatus; + + /** + * Payment Instrument ID + * + * @var int + */ + public $payment_instrument_id; + /** * Explicitly declare the form context. */ @@ -590,7 +598,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $paneNames[ts('Premium Information')] = 'Premium'; } - $this->payment_instrument_id = CRM_Utils_Array::value('payment_instrument_id', $defaults, $this->getDefaultPaymentInstrumentId()); + $this->payment_instrument_id = $defaults['payment_instrument_id'] ?? $this->getDefaultPaymentInstrumentId(); CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->payment_instrument_id); if (!empty($this->_recurPaymentProcessors)) { $buildRecurBlock = TRUE; -- 2.25.1