function getlocations_fields_field_settings_form in Get Locations 7
Same name and namespace in other branches
- 7.2 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_field_settings_form()
Implements hook_field_settings_form(). Add settings to a field settings form.
Invoked from field_ui_field_settings_form() to allow the module defining the field to add global settings (i.e. settings that do not depend on the bundle or instance) to the field settings form. If the field already has data, only include settings that are safe to change.
@todo: Only the field type module knows which settings will affect the field's schema, but only the field storage module knows what schema changes are permitted once a field already has data. Probably we need an easy way for a field type module to ask whether an update to a new schema will be allowed without having to build up a fake $prior_field structure for hook_field_update_forbid().
Parameters
$field: The field structure being configured.
$instance: The instance structure being configured.
$has_data: TRUE if the field already has data, FALSE if not.
Return value
The form definition for the field settings.
File
- modules/
getlocations_fields/ getlocations_fields.module, line 491 - getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function getlocations_fields_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
if (empty($settings)) {
$settings = getlocations_fields_field_info();
}
$form = array();
$form += getlocations_fields_input_settings_form($settings);
// validation for getlocations_fields_input_settings_form
$form['input_address_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_name_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_street_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_additional_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_city_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_province_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_postal_code_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_latitude_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_longitude_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_country_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_phone_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_mobile_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_fax_width']['#element_validate'] = array(
'element_validate_integer_positive',
);
$form['input_map_show'] = getlocations_element_map_checkbox(t('Show map on input form'), $settings['input_map_show']);
$form['mapwidth'] = getlocations_element_map_tf(t('Input form Map width'), $settings['mapwidth'], t('The width of a map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'), 10, 10, TRUE);
$form['mapwidth']['#element_validate'] = array(
'getlocations_element_validate_dim',
);
$form['mapheight'] = getlocations_element_map_tf(t('Input form Map height'), $settings['mapheight'], t('The height of a map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'), 10, 10, TRUE);
$form['mapheight']['#element_validate'] = array(
'getlocations_element_validate_dim',
);
$form['latlong'] = getlocations_element_map_tf(t('Input form Map center'), $settings['latlong'], t('The default center coordinates of a map, expressed as a decimal latitude and longitude, separated by a comma. This must not be 0,0'), 40, 50, TRUE);
$form['latlong']['#element_validate'] = array(
'getlocations_element_validate_latlon',
);
// smart_ip latlon option
if (module_exists('smart_ip')) {
$form['use_smart_ip_latlon'] = getlocations_element_map_checkbox(t('Use Smart IP to set Latitude/Longitude'), $settings['use_smart_ip_latlon'], t('Use Smart IP module to set the default center coordinates.'));
}
else {
$form['use_smart_ip_latlon'] = array(
'#type' => 'value',
'#value' => 0,
);
}
// what3words
$what3words_lic = variable_get('getlocations_what3words_lic', array(
'key' => '',
'url' => 'http://api.what3words.com',
));
if ($what3words_lic['key']) {
$form['what3words_collect'] = getlocations_element_map_checkbox(t('Collect What3Words'), $settings['what3words_collect'], '');
}
// input form marker
$markers = getlocations_get_marker_titles();
$form['input_map_marker'] = getlocations_element_map_marker(t('Input form Map marker'), $markers, $settings['input_map_marker']);
$form['zoom'] = getlocations_element_map_zoom(t('Zoom'), $settings['zoom'], t('The default zoom level of a map.'));
$form += getlocations_map_display_options_form($settings, FALSE, FALSE);
unset($form['#theme']);
$form['#theme'] = 'getlocations_fields_field_settings_form';
return $form;
}