$this->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
$this->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . 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();
}
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;
}
* 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;
$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) {