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 dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
#autocomplete_path
is removed and replaced with #autocomplete_route_name
and #autocomplete_route_parameters
D7
$form['name'] = array(
'#type' => 'textfield',
'#autocomplete_path' => 'user/autocomplete',
);
D8
$form['name'] = array(
'#type' => 'textfield',
'#autocomplete_route_name' => 'user.autocomplete',
);
If values need to be appended to the end of the path, like the taxonomy term autocomplete, there is an #autocomplete_route_parameters
property that takes an associative array of parameters. The keys must match the method parameters of the autocomplete controller.
D7
$form['term'] = array(
'#type' => 'textfield',
'#autocomplete_path' => 'taxonomy/autocomplete/' . $field_name,
);
D8
$form['term'] = array(
'#type' => 'textfield',
'#autocomplete_route_name' => 'taxonomy.autocomplete',
'#autocomplete_route_parameters' => array('field_name' => $field_name),
);
Impacts:
Module developers