From 2c6b06012bfa926e84cd218f556f6477c78f13fe Mon Sep 17 00:00:00 2001 From: Xavier Dutoit Date: Thu, 13 Jun 2013 13:45:49 +0200 Subject: [PATCH] patch as transmited by charles cook --- CRM/Campaign/Form/Petition/Signature.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CRM/Campaign/Form/Petition/Signature.php b/CRM/Campaign/Form/Petition/Signature.php index 7c77d30180..2bfe2cd12a 100644 --- a/CRM/Campaign/Form/Petition/Signature.php +++ b/CRM/Campaign/Form/Petition/Signature.php @@ -283,6 +283,9 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form { } $this->setDefaults($this->_defaults); + + // add in all state country selectors for enabled countries + CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults); } public function buildQuickForm() { @@ -584,6 +587,9 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form { */ function buildCustom($id, $name, $viewOnly = FALSE) { + // create state country map array to hold selectors + $stateCountryMap = array(); + if ($id) { $session = CRM_Core_Session::singleton(); $this->assign("petition", $this->petition); @@ -624,7 +630,15 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form { // ignore file upload fields continue; } - + + // if state or country in the profile, create map + list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2); + if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') { + if (!array_key_exists($index, $stateCountryMap)) { + $stateCountryMap[$index] = array(); + } + $stateCountryMap[$index][$prefixName] = $key; + } CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE); $this->_fields[$key] = $field; @@ -633,6 +647,9 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form { } } + // initialize the state country map + CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap); + if ($addCaptcha && !$viewOnly ) { -- 2.25.1