You are here

function tzfield_autocomplete in Time Zone Field 6

Same name and namespace in other branches
  1. 7 tzfield.module \tzfield_autocomplete()

Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for timezones

2 string references to 'tzfield_autocomplete'
tzfield_menu in ./tzfield.module
Implementation of hook_menu().
tzfield_widget in ./tzfield.module
Implementation of hook_widget().

File

./tzfield.module, line 337
Defines a field type for storing timezones.

Code

function tzfield_autocomplete($field_name, $string = '') {
  $fields = content_fields();
  $field = $fields[$field_name];
  if (arg(4)) {
    $string .= '/' . arg(4);
  }
  if (arg(5)) {
    $string .= '/' . arg(5);
  }
  $string = trim($string);
  $string = str_replace(' ', '_', $string);
  $string = preg_replace(';[^a-z0-9/_-];i', '', $string);
  $return = $string ? preg_grep(';' . $string . ';i', tzfield_timezones($field)) : array();
  drupal_json($return);
}