From c0eb40c14a003e3ef3035c3e2170bb8001e1f248 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 16 Sep 2015 16:23:44 +0530 Subject: [PATCH] CRM-17227: Error thrown while saving profile in Contribution page ---------------------------------------- * CRM-17227: Error thrown while saving profile in Contribution page https://issues.civicrm.org/jira/browse/CRM-17227 --- CRM/Contribute/Form/ContributionPage.php | 1 + .../Form/ContributionPage/Custom.php | 20 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index 09889fd453..9860752e1d 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -136,6 +136,7 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { if (isset($this->_id) && $this->_id) { $params = array('id' => $this->_id); CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values); + CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values); } $this->set('values', $this->_values); } diff --git a/CRM/Contribute/Form/ContributionPage/Custom.php b/CRM/Contribute/Form/ContributionPage/Custom.php index 36c6bd4952..54c8c175b7 100644 --- a/CRM/Contribute/Form/ContributionPage/Custom.php +++ b/CRM/Contribute/Form/ContributionPage/Custom.php @@ -73,7 +73,7 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co $this->addProfileSelector('custom_pre_id', ts('Include Profile') . '
' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE); $this->addProfileSelector('custom_post_id', ts('Include Profile') . '
' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id); + $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this); parent::buildQuickForm(); } @@ -86,14 +86,8 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co public function setDefaultValues() { $defaults = parent::setDefaultValues(); - $ufJoinParams = array( - 'module' => 'CiviContribute', - 'entity_table' => 'civicrm_contribution_page', - 'entity_id' => $this->_id, - ); - list($defaults['custom_pre_id'], - $second) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); - $defaults['custom_post_id'] = $second ? array_shift($second) : ''; + $defaults['custom_pre_id'] = $this->_values['custom_pre_id']; + $defaults['custom_post_id'] = $this->_values['custom_post_id']; return $defaults; } @@ -156,19 +150,19 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co * The input form values. * * @param $files - * @param int $contributionPageId + * @param object $form * * @return bool|array * true if no errors, else array of errors */ - public static function formRule($fields, $files, $contributionPageId) { + public static function formRule($fields, $files, $form) { $errors = array(); $preProfileType = $postProfileType = NULL; // for membership profile make sure Membership section is enabled // get membership section for this contribution page $dao = new CRM_Member_DAO_MembershipBlock(); $dao->entity_table = 'civicrm_contribution_page'; - $dao->entity_id = $contributionPageId; + $dao->entity_id = $form->_id; $membershipEnable = FALSE; @@ -194,7 +188,7 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co $errors['custom_post_id'] = $errorMsg; } - $behalf = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_for_organization'); + $behalf = (!empty($form->_values['onbehalf_profile_id'])) ? $form->_values['onbehalf_profile_id'] : NULL; if ($fields['custom_pre_id']) { $errorMsg = ts('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'); if ($preProfileType == 'Membership' && $behalf) { -- 2.25.1