worked on CRM-12681, fixed display of copy checkbox when billing block is build witho...
authorKurund Jalmi <kurund@civicrm.org>
Mon, 27 May 2013 15:14:39 +0000 (20:44 +0530)
committerKurund Jalmi <kurund@civicrm.org>
Mon, 27 May 2013 15:14:39 +0000 (20:44 +0530)
CRM/Contribute/Form/Contribution/Main.php
CRM/Core/Payment/ProcessorForm.php
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Register.php

index 332ebcba8c73be8a691e9307b03c30547cdcbdbc..8112cda30ef38b1deca8c9a8c7874e823461096d 100644 (file)
@@ -365,6 +365,19 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
    * @access public
    */
   public function buildQuickForm() {
+    // build profiles first so that we can determine address fields etc
+    // and then show copy address checkbox
+    $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
+    $this->buildCustom($this->_values['custom_post_id'], 'customPost');
+
+    if (!empty($this->_fields)) {
+      $profileAddressFields = array();
+      foreach ($this->_fields as $key => $value) {
+        CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
+      }
+      $this->set('profileAddressFields', $profileAddressFields);
+    }
+
     // Build payment processor form
     if ($this->_ppType) {
       CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
@@ -486,17 +499,6 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       }
     }
 
-    $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
-    $this->buildCustom($this->_values['custom_post_id'], 'customPost');
-
-    if ( !empty( $this->_fields ) ) {
-      $profileAddressFields = array();
-      foreach( $this->_fields as $key => $value ) {
-        CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
-      }
-      $this->set('profileAddressFields', $profileAddressFields);
-    }
-
     //to create an cms user
     if (!$this->_userID) {
       $createCMSUser = FALSE;
index eb51b452b890c97cc4706eb80a97dbedb4910889..347eea52395e4c7c19a10efbca99ed16cc0fa24d 100644 (file)
@@ -105,16 +105,16 @@ class CRM_Core_Payment_ProcessorForm {
         )
       );
     }
-
-    $profileAddressFields = $form->get('profileAddressFields');
-    if (!empty( $profileAddressFields)) {
-      $form->assign('profileAddressFields', $profileAddressFields);
-    }
   }
 
   static function buildQuickform(&$form) {
     $form->addElement('hidden', 'hidden_processor', 1);
 
+    $profileAddressFields = $form->get('profileAddressFields');
+    if (!empty($profileAddressFields)) {
+      $form->assign('profileAddressFields', $profileAddressFields);
+    }
+
     // before we do this lets see if the payment processor has implemented a buildForm method
     if (method_exists($form->_paymentProcessor['instance'], 'buildForm') &&
       is_callable(array($form->_paymentProcessor['instance'], 'buildForm'))) {
index 9b1c30802025316520a1b89c7e8b43d4f80a8456..56a1e1acdd6dc6f07c156c61cbe546e0389f428a 100644 (file)
@@ -688,7 +688,6 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
         CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID);
       }
       $this->assign($name, $fields);
-      $profileAddressFields = array();
       if (is_array($fields)) {
         foreach ($fields as $key => $field) {
           if ($viewOnly &&
@@ -715,15 +714,12 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
             }
             $stateCountryMap[$index][$prefixName] = $key;
           }
-          CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
           CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
 
           $this->_fields[$key] = $field;
         }
       }
-      if (!empty($profileAddressFields)) {
-        $this->set('profileAddressFields', $profileAddressFields);
-      }
+
       CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
 
       if ($addCaptcha && !$viewOnly) {
index a2eb53b55b73dfa208e37e0dff12fee3418cc6a6..1d46ace555aec802ffccaa2cb88a37408f301712 100644 (file)
@@ -333,6 +333,19 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    * @access public
    */
   public function buildQuickForm() {
+    // build profiles first so that we can determine address fields etc
+    // and then show copy address checkbox
+    $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
+    $this->buildCustom($this->_values['custom_post_id'], 'customPost');
+
+    if (!empty($this->_fields)) {
+      $profileAddressFields = array();
+      foreach ($this->_fields as $key => $value) {
+        CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
+      }
+      $this->set('profileAddressFields', $profileAddressFields);
+    }
+
     // Build payment processor form
     if ($this->_ppType) {
       CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
@@ -405,9 +418,6 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
     $this->assign('isAdditionalParticipants', $isAdditionalParticipants);
 
-    $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
-    $this->buildCustom($this->_values['custom_post_id'], 'customPost');
-
     //lets get js on two different qf elements.
     $showHidePayfieldName = NULL;
     $showHidePaymentInformation = FALSE;