From: Eileen McNaughton Date: Sat, 14 Oct 2023 20:57:53 +0000 (+1300) Subject: Php8.x bring handling of other_amount back to relevant form X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=18fb1fe9f98548eb09d77cc1d20f35d06460b961;p=civicrm-core.git Php8.x bring handling of other_amount back to relevant form --- 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; }