function _ip_geoloc_set_my_location_add_region in IP Geolocation Views & Maps 7
1 call to _ip_geoloc_set_my_location_add_region()
- ip_geoloc_set_location_form in ./
ip_geoloc_blocks.inc - Form for finding the visitor or going to a region or street address.
File
- ./
ip_geoloc_blocks.inc, line 585 - Blocks available in IP Geolocation Views & Maps.
Code
function _ip_geoloc_set_my_location_add_region(&$form, $location, $geo_vocabulary_id) {
$regions = array(
0 => '--' . t('none') . '--',
);
foreach (taxonomy_get_tree($geo_vocabulary_id) as $term) {
$regions[$term->tid] = str_repeat('-', $term->depth) . $term->name;
if (isset($location['region']) && $location['region'] == $term->tid) {
$current_region_name = $term->name;
}
}
if (variable_get('ip_geoloc_region_autocomplete')) {
// Use an autocomplete textfield, instead of a drop-down selector.
$form['region'] = array(
'#type' => 'textfield',
'#size' => 29,
'#default_value' => isset($current_region_name) ? $current_region_name : '',
'#description' => t('Type the first letters of a region.'),
// Refer to hook_menu().
'#autocomplete_path' => 'ip_geoloc/region_autocomplete',
'#executes_submit_callback' => TRUE,
'#weight' => 10,
);
}
else {
$form['region'] = array(
'#type' => 'select',
'#options' => $regions,
'#default_value' => isset($location['region']) ? $location['region'] : 0,
'#weight' => 10,
);
}
$form['region']['#states'] = array(
'visible' => array(
'select[name="fixed_address"]' => array(
'value' => '2',
),
),
);
}