You are here

function process_gmap_control in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap.module \process_gmap_control()
  2. 6 gmap.module \process_gmap_control()
  3. 7.2 gmap.module \process_gmap_control()
  4. 7 gmap.module \process_gmap_control()

Generic gmap control #process function.

1 string reference to 'process_gmap_control'
gmap_elements in ./gmap.module
Implementation of hook_elements().

File

./gmap.module, line 609
GMap -- Routines to use the Google Maps API in Drupal.

Code

function process_gmap_control($element, $edit, &$form_state, $complete_form) {
  $control = substr($element['#type'], 5);
  $element['#type'] = $element['#gmap_newtype'];
  unset($element['#gmap_newtype']);
  gmap_widget_setup($element, $control);

  // Attempt to run any #process handlers of our transmogrified type.
  // However, if we aren't the only #process handler, we assume someone else
  // is taking care of setting up any default handlers.
  $chain = FALSE;
  if (count($element['#process']) == 1) {

    // Unset #process so we can pull in the default.
    unset($element['#process']);
    $chain = TRUE;
  }

  // Inherit #input from the new type.
  unset($element['#input']);

  // Merge in the defaults for the target element type.
  $element += _element_info($element['#type']);
  if (isset($element['#input']) && $element['#input']) {
    if (isset($element['#process']) && $chain) {

      // Chain process.
      foreach ($element['#process'] as $process) {
        if (function_exists($process)) {
          $form = $process($element, $edit, $form_state, $complete_form);
        }
      }
    }
  }
  return $element;
}