diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index fd23144e9bf9..2187147acd2b 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -341,12 +341,14 @@ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); if (empty($this->_ccid)) { - $this->add('text', "email-{$this->_bltID}", - ts('Email Address'), - array('size' => 30, 'maxlength' => 60, 'class' => 'email'), - TRUE - ); - $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); + if ($this->_emailExists == FALSE) { + $this->add('text', "email-{$this->_bltID}", + ts('Email Address'), + array('size' => 30, 'maxlength' => 60, 'class' => 'email'), + TRUE + ); + $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email'); + } } else { $this->addElement('hidden', "email-{$this->_bltID}", 1); diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 7655c6a31006..72bd332241c6 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -187,6 +187,13 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { */ public $_isBillingAddressRequiredForPayLater; + /** + * Flag if email field exists in embedded profile + * + * @var bool + */ + public $_emailExists = FALSE; + /** * Is this a backoffice form * (this will affect whether paypal express code is displayed) @@ -639,10 +646,12 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = ); if ($fields) { - // unset any email-* fields since we already collect it, CRM-2888 - foreach (array_keys($fields) as $fieldName) { - if (substr($fieldName, 0, 6) == 'email-' && !in_array($profileContactType, array('honor', 'onbehalf'))) { - unset($fields[$fieldName]); + // determine if email exists in profile so we know if we need to manually insert CRM-2888, CRM-15067 + foreach ($fields as $key => $field) { + if (substr($key, 0, 6) == 'email-' && + !in_array($profileContactType, array('honor', 'onbehalf')) + ) { + $this->_emailExists = TRUE; } } @@ -834,11 +843,13 @@ public function buildComponentForm($id, $form) { if (empty($member['is_active'])) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_values['onbehalf_profile_id']); - foreach (array( + foreach ( + array( 'Individual', 'Organization', 'Household', - ) as $contactType) { + ) as $contactType + ) { if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || in_array('Contribution', $onBehalfProfile)