function 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_element_info in modules/
system/ system.module - Implements hook_element_info().
File
-
includes/
form.inc, line 4025
Code
function form_process_autocomplete($element) {
$element['#autocomplete_input'] = array();
if ($element['#autocomplete_path'] && drupal_valid_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;
// Force the script path to 'index.php', in case the server is not
// configured to find it automatically. Normally it is the responsibility
// of the site to do this themselves using hook_url_outbound_alter() (see
// url()) but since this code is forcing non-clean URLs on sites that don't
// normally use them, it is done here instead.
$element['#autocomplete_input']['#url_value'] = url($element['#autocomplete_path'], array(
'absolute' => TRUE,
'script' => 'index.php',
));
$GLOBALS['conf']['clean_url'] = $current_clean_url;
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.