function geofield_field_widget_settings_form in Geofield 7
Same name and namespace in other branches
- 7.2 geofield.widgets.inc \geofield_field_widget_settings_form()
Implements hook_field_widget_settings_form().
File
- ./
geofield.widgets.inc, line 54 - Provides field widget hooks for geofield module.
Code
function geofield_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = $widget['settings'];
$form = array();
//TODO: Allow more fine-grained control
if ($widget['type'] == 'geofield_openlayers') {
// Get preset options, filtered to those which have the GeoField behavior and *don't* have the draw features behavior, which is incompatible
$maps = openlayers_maps();
$map_options = array();
foreach ($maps as $map) {
if (array_key_exists('openlayers_behavior_geofield', $map->data['behaviors']) && !array_key_exists('openlayers_behavior_drawfeatures', $map->data['behaviors'])) {
$map_options[$map->name] = $map->title;
}
}
if (empty($map_options)) {
form_set_error('openlayers_map', "Error: You have no compatible openlayers maps. Make sure that at least one preset has the 'GeoField' behavior enabled and that it does not have the 'Draw Features' behavior enabled (which is incompatible).");
}
$form['openlayers_map'] = array(
'#type' => 'select',
'#title' => t('OpenLayers Map'),
'#default_value' => isset($settings['openlayers_map']) ? $settings['openlayers_map'] : 'geofield_widget_map',
'#options' => $map_options,
'#description' => t('Select which OpenLayers map you would like to use. Only maps which have the GeoField behavior may be selected. If your preferred map is not here, add the GeoField behavior to it first. The "Draw Features" bahavior is incompatible - presets with this behavior are not shown.'),
);
$form['data_storage'] = array(
'#type' => 'radios',
'#title' => t('Storage Options'),
'#description' => t('Should the widget only allow simple features (points, lines, or polygons), or should the widget allow for complex features? Note that changing this setting from complex to simple after data has been entered can lead to data loss.'),
'#options' => array(
'collection' => 'Store as a single collection.',
'single' => 'Store each simple feature as a separate field.',
),
'#default_value' => isset($settings['data_storage']) ? $settings['data_storage'] : 'collection',
);
}
return $form;
}