Posted by Berdir on January 29, 2013 at 12:14am
Project:
Drupal core
Introduced in branch:
8.x Issues:
Description:
The #autocomplete_path form API property has been changed to to pass the search query string as the GET argument q because the new router system breaks the ability to have '/' in a search string.
The two affected autocomplete implementations in core are user/autocomplete and taxonomy/autocomplete/field_name. The request for the user autocomplete with the search string "Ad" is changed from user/autocomplete/Ad to user/autocomplete?q=Ad.
Page callbacks/controllers need to be updated to read the search string from the request object.
7.x
<?php
function mymodule_autocomplete($string = '') {
// If the request has a '/' in the search text, then the menu system will have
// split it into multiple arguments, recover the intended $string.
$args = func_get_args();
$string = implode('/', $args);
// ...
}
?>8.x
<?php
function mymodule_autocomplete() {
$string = Drupal::service('request')->query->get('q');
// ...
}
?>Impacts:
Module developers