$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
- /* FIXME: dirty hack to make the default option show up first. This
- * avoids a mozilla browser bug with defaults on dynamically constructed
- * selector widgets. */
-
+ // Pass default location to js
if ($defaultLocationType) {
- $defaultLocation = $this->_location_types[$defaultLocationType->id];
- unset($this->_location_types[$defaultLocationType->id]);
- $this->_location_types = array(
- $defaultLocationType->id => $defaultLocation) + $this->_location_types;
+ $this->assign('defaultLocationType', $defaultLocationType->id);
+ $this->assign('defaultLocationTypeLabel', $this->_location_types[$defaultLocationType->id]);
}
/* Initialize all field usages to false */
-
foreach ($mapperKeys as $key) {
$this->_fieldUsed[$key] = FALSE;
}
cj('select[id^="mapper"][id$="[0]"]').addClass('huge');
{/literal}
{include file="CRM/common/highLightImport.tpl" relationship=true}
+
+ {* // Set default location type *}
+ {literal}
+ cj(function() {
+ var defaultLocationType = "{/literal}{$defaultLocationType}{literal}";
+ if (defaultLocationType.length) {
+ cj('#map-field').on('change', 'select[id^="mapper"][id$="_0"]', function() {
+ var select = cj(this).next();
+ cj('option', select).each(function() {
+ if (cj(this).attr('value') == defaultLocationType
+ && cj(this).text() == "{/literal}{$defaultLocationTypeLabel}{literal}") {
+ select.val(defaultLocationType);
+ }
+ });
+ });
+ }
+ });
+ {/literal}
</script>
</div>
{/if}