function _location_expand_location_settings in Location 5.3
Same name and namespace in other branches
- 6.3 location.module \_location_expand_location_settings()
- 7.4 location.module \_location_expand_location_settings()
File
- ./
location.module, line 348 - Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…
Code
function _location_expand_location_settings($element) {
$value = is_array($element['#value']) ? $element['#value'] : array();
$element['#tree'] = TRUE;
$element['#theme'] = 'location_settings';
if (!isset($element['#title'])) {
$element['#title'] = t('Location Fields');
}
if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
$element['#default_value'] = array();
}
// Force #tree on.
$element['#tree'] = TRUE;
$defaults = $element['#default_value'];
if (!isset($defaults) || !is_array($defaults)) {
$defaults = array();
}
$temp = location_invoke_locationapi($element, 'defaults');
foreach ($temp as $k => $v) {
if (!isset($defaults[$k])) {
$defaults[$k] = array();
}
$defaults[$k] = array_merge($v, $defaults[$k]);
}
$fields = location_field_names();
// Options for fields.
$options = array(
0 => t('Do not collect'),
1 => t('Allow'),
2 => t('Require'),
4 => t('Force Default'),
);
foreach ($fields as $field => $title) {
$element[$field] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
);
$element[$field]['name'] = array(
'#type' => 'item',
'#value' => $title,
);
$element[$field]['collect'] = array(
'#type' => 'select',
'#default_value' => $defaults[$field]['collect'],
'#options' => $options,
);
$temp = $defaults[$field]['default'];
$element[$field]['default'] = location_invoke_locationapi($temp, 'field_expand', $field, 1, $defaults);
$defaults[$field]['default'] = $temp;
$element[$field]['weight'] = array(
'#type' => 'weight',
'#delta' => 100,
'#default_value' => $defaults[$field]['weight'],
);
}
// 'Street Additional' field should depend on 'Street' setting.
// It should never be required and should only display when the street field is 'allowed' or 'required'
// unset($element['additional']);
// @@@ Alter here?
return $element;
}