From faf468e7937ceafc2a5045bb87f442a4a56e9a83 Mon Sep 17 00:00:00 2001 From: yashodha Date: Wed, 6 Nov 2013 15:17:29 +0530 Subject: [PATCH] CRM-13617 - link custom data for country to state/province drop downs --- CRM/Core/BAO/CustomField.php | 2 ++ CRM/Core/BAO/UFGroup.php | 9 ++++++++- CRM/Profile/Form.php | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 1e89e8a3c1..5177c1c53e 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -958,6 +958,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $useRequired && !$search, $dataCrmCustomAttr ); + $qf->_stateCountryMap['state_province'][] = $elementName; break; case 'Multi-Select State/Province': @@ -977,6 +978,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $useRequired && !$search, $dataCrmCustomAttr ); + $qf->_stateCountryMap['country'][] = $elementName; break; case 'Multi-Select Country': diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index e11eff9a23..d9ff4a0f4c 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -2184,7 +2184,14 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) 'non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) { $form->addRule($name, ts('Please enter a valid amount.'), 'money'); } - + $stateCountryMap = array(); + if (!empty($form->_stateCountryMap['state_province']) && !empty($form->_stateCountryMap['country'])) { + foreach ($form->_stateCountryMap['state_province'] as $key => $value) { + $stateCountryMap[$key]['state_province'] = $value; + $stateCountryMap[$key]['country'] = $form->_stateCountryMap['country'][$key]; + } + CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap); + } if ($rule) { if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) { $form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule); diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 27d9d21e56..21c0d2b33d 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -180,6 +180,7 @@ class CRM_Profile_Form extends CRM_Core_Form { protected $_currentUserID = NULL; protected $_session = NULL; + public $_stateCountryMap = array(); /** * pre processing work done here. * -- 2.25.1