CRM-17865: set participant custom field defaults on additional reg form
authorBrian Shaughnessy <brian@lcdservices.biz>
Sat, 23 Jan 2016 19:37:13 +0000 (14:37 -0500)
committerBrian Shaughnessy <brian@lcdservices.biz>
Sat, 23 Jan 2016 19:37:13 +0000 (14:37 -0500)
CRM/Event/Form/Registration/AdditionalParticipant.php

index 4b30cbc9f1b59806e95e700188c602f94a049099..d8429d669141837684a57f69153182e2588db6d6 100644 (file)
@@ -148,6 +148,19 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R
       $defaults['participant_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
     }
 
+    //CRM-17865 set custom field defaults
+    if (!empty($this->_fields)) {
+      foreach ($this->_fields as $name => $field) {
+        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
+          if (!isset($defaults[$name])) {
+            CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults,
+              NULL, CRM_Profile_Form::MODE_REGISTER
+            );
+          }
+        }
+      }
+    }
+
     return $defaults;
   }