Php8.x bring handling of other_amount back to relevant form
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 14 Oct 2023 20:57:53 +0000 (09:57 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 15 Oct 2023 21:58:43 +0000 (10:58 +1300)
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Price/BAO/PriceField.php

index 10d7e5f55e0f8fc162a92c1da5a160d465cd20af..3deaec2b7eb4fc21291b8cf14144e9ec195d5052 100644 (file)
@@ -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
           );
index d1d2f8a232679676a0f323c06b4c64d8bd2efb57..e291f8c16cb738e98403bbad93a3b666b3fd5bb6 100644 (file)
@@ -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
           );
         }
index 0fb1c2e609072b24205a93814868ef05b7ea1b3a..7ed8a664fb53ad6f689d04598db4befc90feb6ae 100644 (file)
@@ -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;
     }