From: Kurund Jalmi Date: Mon, 27 May 2013 15:14:39 +0000 (+0530) Subject: worked on CRM-12681, fixed display of copy checkbox when billing block is build witho... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4839c695c9e0d381963e5a76d8c356f46e02f1f4;p=civicrm-core.git worked on CRM-12681, fixed display of copy checkbox when billing block is build without ajax --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 332ebcba8c..8112cda30e 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -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; diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index eb51b452b8..347eea5239 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -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'))) { diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 9b1c308020..56a1e1acdd 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -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) { diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index a2eb53b55b..1d46ace555 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -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;