You are here

function _location_country_ajax_callback in Location 7.5

Same name and namespace in other branches
  1. 7.3 location.module \_location_country_ajax_callback()

AJAX callback for the Country select form, for cases where the province list is also a select element and its options need to be updated. Uses the D7 Ajax Framework to do the select list updating.

All we do here is select the element of the form that will be rebuilt.

1 string reference to '_location_country_ajax_callback'
location_locationapi in ./location.module
Implements hook_locationapi().

File

./location.module, line 1096
Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…

Code

function _location_country_ajax_callback($form, $form_state) {

  // The isset() checks, ideally, wouldn't ever have to happen because, ideally,
  // this code would never get called, because, ideally, we wouldn't add an
  // ajax call to the country field.  Unfortunately, however, there's no easy
  // way to check whether or not the province is being collected when putting
  // together the country form element in location_locationapi() when that
  // function is called with $op == 'field_expand'
  if (arg(2) == 'locations' && isset($form['locations'][arg(3)]['province'])) {
    return $form['locations'][arg(3)]['province'];
  }
  elseif (isset($form[arg(2)][arg(3)][arg(4)])) {
    return $form[arg(2)][arg(3)][arg(4)]['province'];
  }
}