Search code examples
drupalautocompletedrupal-7

Drupal 7 grouping of autocomplete suggestions


I have an places autocomplete textfield. With the core drupal autocomplete i am able to show suggestions of places.

Now i need to group these suggestions by type à la OS X spotlight. Example :

  • Hotels (34)
    • Hotel 1
    • Hotel 2
    • ...
  • Restaurants (65)
    • Restaurant 1
    • ...

How do i override drupal's autocomplete to achieve this ? Or should i build this independently from drupal's autocomplete ?


Solution

  • (Reference: http://bitnr.drupalgardens.com/content/autocomplete-callbacks-drupal-7-or-fun-dbqueryrange-and)

    I believe you only get to return a flat array, similar to D6.

    I would solve this with jQuery and AJAX.