You are here

function form_process_autocomplete in Drupal 6

Same name and namespace in other branches
  1. 7 includes/form.inc \form_process_autocomplete()

Process function to prepare autocomplete data.

Parameters

$element: A textfield or other element with a #autocomplete_path.

Return value

array The processed form element.

Related topics

1 string reference to 'form_process_autocomplete'
system_elements in modules/system/system.module
Implementation of hook_elements().

File

includes/form.inc, line 2129

Code

function form_process_autocomplete($element) {
  $element['#autocomplete_input'] = array();
  if ($element['#autocomplete_path'] && menu_valid_path(array(
    'link_path' => $element['#autocomplete_path'],
  ))) {
    $element['#autocomplete_input']['#id'] = $element['#id'] . '-autocomplete';

    // Force autocomplete to use non-clean URLs since this protects against the
    // browser interpreting the path plus search string as an actual file.
    $current_clean_url = isset($GLOBALS['conf']['clean_url']) ? $GLOBALS['conf']['clean_url'] : NULL;
    $GLOBALS['conf']['clean_url'] = 0;
    $element['#autocomplete_input']['#url_value'] = check_url(url($element['#autocomplete_path'], array(
      'absolute' => TRUE,
    )));
    $GLOBALS['conf']['clean_url'] = $current_clean_url;
  }
  return $element;
}