return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
+ /**
+ *CRM-17797 -- Format fields and setDefaults for primary and additional participants profile
+ *@param int $contactId
+ *@param $form array
+ */
+ public static function formatFieldsAndSetProfileDefaults($contactId, &$form) {
+ if (!$contactId) {
+ return;
+ }
+ $fields = array();
+ if (!empty($form->_fields)) {
+ $removeCustomFieldTypes = array('Participant');
+
+ foreach ($form->_fields as $name => $dontCare) {
+ if ((substr($name, 0, 7) == 'custom_' && !$form->_allowConfirmation
+ && !CRM_Core_BAO_CustomGroup::checkCustomField(substr($name, 7), $removeCustomFieldTypes))
+ || substr($name, 0, 12) == 'participant_') {
+ continue;
+ }
+ $fields[$name] = 1;
+ }
+
+ if (!empty($fields)) {
+ CRM_Core_BAO_UFGroup::setProfileDefaults($contactId, $fields, $form->_defaults);
+ }
+ }
+ }
+
}
$this->_discountId = $discountId;
$this->_pId = $this->_additionalParticipantId;
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_additionalParticipantId, 'contact_id');
+
+ CRM_Event_BAO_Participant::formatFieldsAndSetProfileDefaults($this->_contactId, $this);
$participantDefaults = CRM_Event_Form_EventFees::setDefaultValues($this);
$participantDefaults = array_merge($this->_defaults, $participantDefaults);
// use primary email address if billing email address is empty
$contactID = $this->getContactID();
CRM_Core_Payment_Form::setDefaultValues($this, $contactID);
- if ($contactID) {
- $fields = array();
-
- if (!empty($this->_fields)) {
- $removeCustomFieldTypes = array('Participant');
- foreach ($this->_fields as $name => $dontCare) {
- if (substr($name, 0, 7) == 'custom_') {
- $id = substr($name, 7);
- if (!$this->_allowConfirmation &&
- !CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes)
- ) {
- continue;
- }
- // ignore component fields
- }
- elseif ((substr($name, 0, 12) == 'participant_')) {
- continue;
- }
- $fields[$name] = 1;
- }
- }
- }
-
- if (!empty($fields)) {
- CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults);
- }
+ CRM_Event_BAO_Participant::formatFieldsAndSetProfileDefaults($contactID, $this);
// Set default payment processor as default payment_processor radio button value
if (!empty($this->_paymentProcessors)) {