* when not to reset sort_name
*/
protected $_preserveDefault = TRUE;
+
+ /**
+ * the internal QF names for the state/country/county fields
+ */
+
+ protected $_stateCountryCountyFields = array();
/**
* build all the data structures needed to build the form
'organization_name',
'household_name',
);
+
+ $stateCountryMap = array();
foreach ($this->_contactIds as $contactId) {
$profileFields = $this->_fields;
CRM_Core_BAO_Address::checkContactSharedAddressFields($profileFields, $contactId);
foreach ($profileFields as $name => $field) {
+
+ // Link state to country, county to state per location per contact
+ list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
+ if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
+ $stateCountryMap["$index-$contactId"][$prefixName] = "field_{$contactId}_{$field['name']}";
+ $this->_stateCountryCountyFields["$index-$contactId"][$prefixName] = "field[{$contactId}][{$field['name']}]";
+ }
+
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
if (in_array($field['name'], $preserveDefaultsArray)) {
}
}
}
+
+ CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
+
+
$this->assign('fields', $this->_fields);
}
$this->assign('sortName', $sortName);
+
+ // now fix all state country selectors
+ CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults, $this->_stateCountryCountyFields);
return $defaults;
}
$config->stateCountryMap = array_merge($config->stateCountryMap, $stateCountryMap);
}
- static function fixAllStateSelects(&$form, &$defaults) {
+ static function fixAllStateSelects(&$form, $defaults, $batchFieldNames = false) {
$config = CRM_Core_Config::singleton();
+
+ $map = is_array($batchFieldNames) ? $batchFieldNames : $config->stateCountryMap;
- if (!empty($config->stateCountryMap)) {
- foreach ($config->stateCountryMap as $index => $match) {
+ if (!empty($map)) {
+ foreach ($map as $index => $match) {
if (
array_key_exists('state_province', $match) &&
array_key_exists('country', $match)