Fix for dev/core#2948
authorJaap Jansma <jaap.jansma@civicoop.org>
Wed, 10 Nov 2021 13:10:46 +0000 (14:10 +0100)
committerJaap Jansma <jaap.jansma@civicoop.org>
Wed, 10 Nov 2021 13:10:46 +0000 (14:10 +0100)
CRM/Event/Form/Registration.php

index 12d1cfbecc4fe2d54f3dcaf4e6169c6e9f95ae9a..5ccb819dc5b933cc7bc6148836f5ef0d5fe52a09 100644 (file)
@@ -686,12 +686,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       $this->set('primaryParticipant', $this->_params);
     }
 
-    CRM_Core_BAO_CustomValueTable::postProcess($this->_params,
-      'civicrm_participant',
-      $participant->id,
-      'Participant'
-    );
-
     $createPayment = (CRM_Utils_Array::value('amount', $this->_params, 0) != 0) ? TRUE : FALSE;
 
     // force to create zero amount payment, CRM-5095
@@ -828,6 +822,15 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
       $participantParams['discount_id'] = "null";
     }
 
+    $participantParams['custom'] = [];
+    foreach ($form->_params as $paramName => $paramValue) {
+      if (strpos($paramName, 'custom_') === 0) {
+        list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($paramName, TRUE);
+        CRM_Core_BAO_CustomField::formatCustomField($customFieldID, $participantParams['custom'], $paramValue, 'Participant', $customValueID);
+
+      }
+    }
+
     $participant = CRM_Event_BAO_Participant::create($participantParams);
 
     $transaction->commit();