You are here

function geofield_latlon_element_process in Geofield 7.2

Process function for geofield_latlon.

1 string reference to 'geofield_latlon_element_process'
geofield_element_info in ./geofield.elements.inc
Implements hook_element_info().

File

./geofield.elements.inc, line 71
Provides FormAPI element callbacks for geofield_latlon and geofield_proximity.

Code

function geofield_latlon_element_process($element, &$form_values) {
  $element['#tree'] = TRUE;
  $element['#input'] = TRUE;
  $element['lat'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude'),
    '#required' => !empty($element['#required']) ? $element['#required'] : FALSE,
    '#default_value' => !empty($element['#default_value']['lat']) ? $element['#default_value']['lat'] : '',
    '#attributes' => array(
      'class' => array(
        'geofield-lat',
      ),
    ),
  );
  $element['lon'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude'),
    '#required' => !empty($element['#required']) ? $element['#required'] : FALSE,
    '#default_value' => !empty($element['#default_value']['lon']) ? $element['#default_value']['lon'] : '',
    '#attributes' => array(
      'class' => array(
        'geofield-lon',
      ),
    ),
  );
  unset($element['#value']);

  // Set this to false always to prevent notices.
  $element['#required'] = FALSE;
  if (!empty($element['#geolocation']) && $element['#geolocation'] == TRUE) {
    $element['#attached']['js'][] = drupal_get_path('module', 'geofield') . '/js/geolocation.js';
    $element['geocode'] = array(
      '#type' => 'button',
      '#value' => t('Find my location'),
      '#name' => 'geofield-html5-geocode-button',
    );
    $element['#attributes']['class'] = array(
      'auto-geocode',
    );
  }
  return $element;
}