From 18fb1fe9f98548eb09d77cc1d20f35d06460b961 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 15 Oct 2023 09:57:53 +1300 Subject: [PATCH] Php8.x bring handling of other_amount back to relevant form --- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Contribution/Main.php | 5 +++-- CRM/Price/BAO/PriceField.php | 6 +----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 10d7e5f55e..3deaec2b7e 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1002,7 +1002,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 'price_' . $field['id'], $field['id'], FALSE, - CRM_Utils_Array::value('is_required', $field, FALSE), + $field['is_required'] ?? FALSE, NULL, $options ); diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index d1d2f8a232..e291f8c16c 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -541,12 +541,13 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } } if (!empty($options)) { + $label = (!empty($this->_membershipBlock) && $field['name'] === 'contribution_amount') ? ts('Additional Contribution') : $field['label']; CRM_Price_BAO_PriceField::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, - CRM_Utils_Array::value('is_required', $field, FALSE), - NULL, + $field['is_required'] ?? FALSE, + $label, $options ); } diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 0fb1c2e609..7ed8a664fb 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -256,7 +256,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { /* FIXME: failure! */ return NULL; } - + $label = $label ?: $field['label']; $is_pay_later = 0; $isQuickConfig = CRM_Price_BAO_PriceSet::isQuickConfig($field->price_set_id); if (isset($qf->_mode) && empty($qf->_mode)) { @@ -274,10 +274,6 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { // get currency name for price field and option attributes $currencyName = $config->defaultCurrency; - if (!isset($label)) { - $label = (!empty($qf->_membershipBlock) && $field->name === 'contribution_amount') ? ts('Additional Contribution') : $field->label; - } - if (isset($qf->_online) && $qf->_online) { $useRequired = FALSE; } -- 2.25.1