You are here

function geolocation_html5_field_widget_validate in Geolocation Field 7

Validation handler for geolocation_html5_field_widget_form().

1 string reference to 'geolocation_html5_field_widget_validate'
geolocation_html5_field_widget_form in modules/geolocation_html5/geolocation_html5.module
Implements hook_field_widget_form().

File

modules/geolocation_html5/geolocation_html5.module, line 133
HTML5 widget and formaters for Geolocation.

Code

function geolocation_html5_field_widget_validate($element, &$form_state, $form) {
  if ($element['#required']) {
    if ($element['save']['#value'] && (!$element['lat']['#value'] || !$element['lng']['#value'])) {
      form_error($element, t('!name field is required. You may need to allow your browser detect your location.', array(
        '!name' => $element['#title'],
      )));
    }
  }
}