function geolocation_googlemaps_field_widget_validate in Geolocation Field 7
Validation handler for geolocation_googlemaps_field_widget_form().
1 string reference to 'geolocation_googlemaps_field_widget_validate'
- geolocation_googlemaps_field_widget_form in modules/
geolocation_googlemaps/ geolocation_googlemaps.module - Implements hook_field_widget_form().
File
- modules/
geolocation_googlemaps/ geolocation_googlemaps.module, line 502 - Google Maps widget and formatters for Geolocation.
Code
function geolocation_googlemaps_field_widget_validate($element, &$form_state, $form) {
if ($element['#required']) {
if (!$element['lat']['#value'] || !$element['lng']['#value']) {
form_error($element, t('!name field is required.', array(
'!name' => $element['#title'],
)));
}
}
else {
switch (TRUE) {
case $element['lng']['#value'] && !$element['lat']['#value']:
form_error($element, t('!name field is incomplete, latitude value is missing.', array(
'!name' => $element['#title'],
)));
break;
case !$element['lng']['#value'] && $element['lat']['#value']:
form_error($element, t('!name field is incomplete, longitude value is missing.', array(
'!name' => $element['#title'],
)));
break;
}
}
}