Skip to content
Snippets Groups Projects
location_gmap_find_address.module 1.2 KiB
Newer Older
/**
 * @file
 * The Location GMap Fnd Address module adds a special button
 * to all location fields that use gmap.
 */

 * Implements hook_field_widget_form_alter().
function location_gmap_find_address_field_widget_form_alter(&$element, &$form_state, $context) {
  if ($context['field']['type'] == 'location' && variable_get('location_usegmap', 0)) {
    if (isset($element['#location_settings']['form']['fields']['locpick'])) {
      drupal_add_js(drupal_get_path("module", "location_gmap_find_address") . "/location_gmap_find_address.js");
      $element["#pre_render"] = array('location_gmap_find_address_location_pre_render');
/**
 * Callback for element #pre_render property.
 *
 * @param array $element
 *   Element that will be processed.
 *
 * @return array
 *   An element with prefix property.
 *
 * @see location_gmap_find_address_field_widget_form_alter()
 */
function location_gmap_find_address_location_pre_render($element) {
  $element['locpick']["#prefix"] = '<div class="location-gmap-find-address-button-wrapper"><button type="button" class="location-gmap-find-address-button" value="' . $element['#id'] . '">' . t('Find Address on Map') . '</button></div>';
  return $element;