Move form specific code out of shared function
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 20:06:26 +0000 (09:06 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 28 Nov 2023 20:06:26 +0000 (09:06 +1300)
CRM/Event/Form/Participant.php
CRM/Event/Form/ParticipantFeeSelection.php
CRM/Event/Form/Registration.php

index 280d5539d889808639946ad356f2eaace85532b5..abf1773c41eb5a9ca61834bffb954a6eb207c0aa 100644 (file)
@@ -1253,7 +1253,8 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       CRM_Event_BAO_Event::retrieve($params, $event);
 
       //retrieve custom information
-      $form->_values = [];
+      $this->_values = [];
+      $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'participant');
       CRM_Event_Form_Registration::initEventFee($form, FALSE, $this->getPriceSetID());
       if ($form->_context === 'standalone' || $form->_context === 'participant') {
         $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($event['id'], 'civicrm_event');
index cbb5c49bc866d9993baf0760278fdbe9865100da..9a9ca95276f1afe59e7740c9a56e583742a93965 100644 (file)
@@ -176,6 +176,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form {
     //retrieve custom information
     $this->_values = [];
 
+    $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
     CRM_Event_Form_Registration::initEventFee($this, $this->_action !== CRM_Core_Action::UPDATE, $this->getPriceSetID());
     CRM_Event_Form_Registration_Register::buildAmount($this, TRUE, NULL, $this->getPriceSetID());
 
index 1c7a8fd96c3f2443b8f4e6a626d314cdcb2f2c7f..d2d04ba0ce06470b9120e826124b3818e40a6609 100644 (file)
@@ -315,7 +315,19 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
 
       $priceSetID = $this->getPriceSetID();
       if ($priceSetID) {
+        $this->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
         self::initEventFee($this, TRUE, $priceSetID);
+
+        //fix for non-upgraded price sets.CRM-4256.
+        if (isset($this->_isPaidEvent)) {
+          $isPaidEvent = $this->_isPaidEvent;
+        }
+        else {
+          $isPaidEvent = $this->_values['event']['is_monetary'] ?? NULL;
+        }
+        if ($isPaidEvent && empty($this->_values['fee'])) {
+          CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $this->_eventId)]));
+        }
         $this->assign('quickConfig', $this->isQuickConfig());
       }
 
@@ -606,15 +618,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       return;
     }
 
-    // get price info
-    if ($form->_action & CRM_Core_Action::UPDATE) {
-      if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) {
-        $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_id, 'participant');
-      }
-      else {
-        $form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($form->_participantId, 'participant');
-      }
-    }
     $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, NULL, $doNotIncludeExpiredFields);
     $form->_priceSet = $priceSet[$priceSetId] ?? NULL;
     $form->_values['fee'] = $form->_priceSet['fields'] ?? NULL;
@@ -659,14 +662,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
     if (!is_array($eventFee) || empty($eventFee)) {
       $form->_values['fee'] = [];
     }
-
-    //fix for non-upgraded price sets.CRM-4256.
-    if (isset($form->_isPaidEvent)) {
-      $isPaidEvent = $form->_isPaidEvent;
-    }
-    else {
-      $isPaidEvent = $form->_values['event']['is_monetary'] ?? NULL;
-    }
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()
       && !empty($form->_values['fee'])
     ) {
@@ -678,11 +673,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
         }
       }
     }
-    if ($isPaidEvent && empty($form->_values['fee'])) {
-      if (!in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) {
-        CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)]));
-      }
-    }
   }
 
   /**