Sometimes, it is very handfull to pass to autocomplete route additional parameters, not only the text that come from input textfield.

Example: Form with field "City" (select) and "Street" (autocomplete). I want to search streets only in chosen city.

Yes, I know I can make "#ajax" property for "City" field, then on form ajax rebuild pass the city id to "'#autocomplete_route_parameters' => array('city' => 13)," property of "Street" form field. (I didn't test that way yet).

But there is a way better, without additional ajax requests.

I want to add custom js library, that handle changes of "City" field, and on change it would do something like this:

jQuery.extend(true, Drupal.autocomplete.ajax, {data: {city: 13}});

But then autocomplete should make recursive merge of Drupal.autocomplete.ajax. Please see the patch and jQuery.extend doc:

improve_autocomplete.js_.patch550 bytesandyceo
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 97,317 pass(es). View


andypost’s picture

Issue tags: -JS +JavaScript
andyceo’s picture

Issue summary: View changes
markdorison’s picture

Version: 8.0.0-beta12 » 8.3.x-dev
Assigned: andyceo » Unassigned
droplet’s picture

I like the patch but worrying about the backward compatibility

andypost’s picture

@droplet please point where it breaks BC? I suppose it implementation details that does not affect contrib

droplet’s picture


We didn't expect deep copy before. Data are not filtered in CORE / Contrib.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.