You are here

function process_gmap_control in GMap Module 7.2

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

Generic gmap control #process function.

@todo move this to GmapElement class

1 string reference to 'process_gmap_control'
gmap_element_info in ./gmap.module
Implements hook_element_info().

File

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

Code

function process_gmap_control($element, &$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, $form_state, $complete_form);
        }
      }
    }
  }
  return $element;
}