<?php /** * hook_form_alter() override */ function location_gmap_find_address_form_alter(&$form, &$form_state, $form_id) { if (isset($form['#node_edit_form']) && $form['#node_edit_form'] && variable_get('location_usegmap', 0)) { $fields = field_info_instances($form['#entity_type'], $form['#bundle']); $form['#location_gmap_find_address_fields'] = array(); foreach($fields as $field_name => $field) { if ($field['widget']['type'] == 'location') { $form['#location_gmap_find_address_fields'][] = $field_name; } } if (count($form['#location_gmap_find_address_fields'])) { $form["#after_build"][] = "location_gmap_find_address_after_build"; } } } /** * After build event for this form */ function location_gmap_find_address_after_build($form, &$form_state) { foreach ($form['#location_gmap_find_address_fields'] as $field_name) { $field_instance_count = $form[$field_name]['und']['#max_delta']; for ($i = 0; $i <= $field_instance_count; $i++) { if(isset($form[$field_name]['und'][$i]['locpick'])) { $form[$field_name]['und'][$i]['locpick']["#prefix"] = '<div class="location-gmap-find-address-button-wrapper"><button type="button" class="location-gmap-find-address-button" value="' . str_replace('_', '-', $field_name) . '-und-' . $i . '">' . t('Find Address on Map') . '</button></div>'; } } } drupal_add_js(drupal_get_path("module", "location_gmap_find_address") . "/location_gmap_find_address.js"); return $form; }