function _ip_geoloc_set_my_location_add_logic in IP Geolocation Views & Maps 7
1 call to _ip_geoloc_set_my_location_add_logic()
- 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 626 - Blocks available in IP Geolocation Views & Maps.
Code
function _ip_geoloc_set_my_location_add_logic(&$form, $location, $options, $is_address_editable, $geo_vocabulary_id) {
$fixed_address = empty($location['fixed_address']) ? 0 : (int) $location['fixed_address'];
// Check if we have a "Region/Move to" drop-down ...
if (isset($form['fixed_address'])) {
// Default to "Move to", unless we do not have a location at all, or when
// "Region" was selected and "Go" pressed.
$selected = '1';
if (isset($options['2']) && !isset($location['fixed_address']) || $fixed_address == 2) {
$selected = '2';
}
$form['fixed_address']['#default_value'] = $selected;
}
// Disable the address box when it isn't editable.
$form['street_address']['#disabled'] = !$is_address_editable;
// Special logic for when there's a Region selector
if ($geo_vocabulary_id) {
// If "Move to" is NOT there, remove Address box when Go was pressed.
if (!isset($options['1']) && $fixed_address == 2) {
unset($form['street_address']);
}
elseif (count($options) > 1) {
// If 2 or more options, then hide Address box when Region pressed.
$form['street_address']['#states'] = array(
'invisible' => array(
'select[name="fixed_address"]' => array(
'value' => '2',
),
),
);
}
}
}