Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
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
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
function mymodule_autocomplete() {
$string = Drupal::service('request')->query->get('q');
// ...
}
Impacts:
Module developers