From 5595b06825304f94da19a4e04e50c63ec5c93b10 Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Sat, 12 Aug 2023 13:42:48 -0600 Subject: [PATCH] Fix PCP validation error on Contribution Pages & Events --- CRM/PCP/BAO/PCP.php | 2 +- CRM/PCP/Form/Contribute.php | 2 +- CRM/PCP/Form/Event.php | 16 +++++++++++----- templates/CRM/PCP/Form/PCP.tpl | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index 9ceeb01f4b..0051cd41d6 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -391,7 +391,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id = %2 AND cc.is_test = 0"; $form->assign('profile', $profile); } - $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), ['' => ts('- select -')] + $profile, TRUE, ['class' => 'crm-select2']); + $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), ['' => ts('- select -')] + $profile, FALSE, ['class' => 'crm-select2']); //CRM-15821 - To add new option for PCP "Owner" notification $ownerNotifications = CRM_Core_OptionGroup::values('pcp_owner_notify'); diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index c4c58270e3..e276944c78 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -95,7 +95,7 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { */ public static function formRule($params, $files, $self) { $errors = []; - if (!empty($params['is_active'])) { + if (!empty($params['pcp_active'])) { if (!empty($params['is_tellfriend_enabled']) && (CRM_Utils_Array::value('tellfriend_limit', $params) <= 0) diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index 158e3ecf34..da862b1562 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -125,13 +125,19 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { */ public static function formRule($params, $files, $self) { $errors = []; - if (!empty($params['is_active'])) { + if (!empty($params['pcp_active'])) { - if (!empty($params['is_tellfriend_enabled']) && - (CRM_Utils_Array::value('tellfriend_limit', $params) <= 0) - ) { - $errors['tellfriend_limit'] = ts('if Tell Friend is enable, Maximum recipients limit should be greater than zero.'); + if (!empty($params['is_tellfriend_enabled']) && ($params['is_tellfriend_enabled'] <= 0)) { + $errors['tellfriend_limit'] = ts('If Tell a Friend is enabled, maximum recipients limit should be greater than zero.'); + } + + if (empty($params['target_entity_type'])) { + $errors['target_entity_type'] = ts('Campaign Type is a required field.'); } + elseif (($params['target_entity_type'] === 'contribute') && (empty($params['target_entity_id']))) { + $errors['target_entity_id'] = ts('Online Contribution Page is a required field.'); + } + if (empty($params['supporter_profile_id'])) { $errors['supporter_profile_id'] = ts('Supporter profile is a required field.'); } diff --git a/templates/CRM/PCP/Form/PCP.tpl b/templates/CRM/PCP/Form/PCP.tpl index 156667116d..c96b51bafb 100644 --- a/templates/CRM/PCP/Form/PCP.tpl +++ b/templates/CRM/PCP/Form/PCP.tpl @@ -45,7 +45,7 @@ {$form.notify_email.html} {help id="id-notify"} - {$form.supporter_profile_id.label} + {$form.supporter_profile_id.label} * {$form.supporter_profile_id.html} {help id="id-supporter_profile"} -- 2.25.1