CRM-17878: on behalf still seems to be loading on thankyou page
authoryashodha <yashodha.chaku@webaccessglobal.com>
Fri, 1 Apr 2016 13:26:03 +0000 (18:56 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Fri, 1 Apr 2016 13:26:03 +0000 (18:56 +0530)
----------------------------------------
* CRM-17878: If 'on behalf of organisation' is set to 'optional' and then not chosen, it creates contact with no name and adds the relationship
  https://issues.civicrm.org/jira/browse/CRM-17878

CRM/Contribute/Form/Contribution/ThankYou.php

index 528b6efd3b750e69307c8b8b40c397006f2b5b9f..753d41c7748ad11144822a33e58efed504b1f3b2 100644 (file)
@@ -186,7 +186,12 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
 
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
     $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
-    if (!empty($params['onbehalf'])) {
+    if (!empty($this->_values['onbehalf_profile_id']) &&
+      !empty($params['onbehalf']) &&
+      ($this->_values['is_for_organization'] == 2 ||
+        !empty($params['is_for_organization'])
+      )
+    ) {
       $fieldTypes = array('Contact', 'Organization');
       $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
       $fieldTypes = array_merge($fieldTypes, $contactSubType);