Autocomplete Fix - Drupal Modules

The Problem...

Drupal 6 and 7 still exhibit longstanding quirks with autocomplete fields (where search results appear in a popup list as you type). For the most part autocomplete fields work as-advertised, but somehow they get confused by the humble slash ( / ) character.

In Drupal 6 everything following the first slash in your autocomplete field will be ignored in the autocomplete query. The reason this happens is because autocomplete sends its query to Drupal as a path component, and the Drupal path system throws away anything following the first slash (even if the slash was encoded, which it isn't anyway).

In Drupal 7 the problem is less serious but still wrong. Trailing slashes are ignored in the autocomplete query, so you can't do an autocomplete on the slash character by itself, or as the last character in an autocomplete query.

To get around this issue I've built two Drupal 6 modules that override the behavior of autocomplete fields. The Autocomplete Hack module still submits the search terms through a path parameter, but it specially encodes slashes so they won't confuse the path system. The Autocomplete POST module causes autocomplete fields to submit their contents in a POST header, bypassing the path parameter altogether.

Download

These are proof-of-concept modules and may not work with your particular configuration. Hopefully this issue will be fixed for real in a future version of Drupal, rendering these modules obsolete.

Download Autocomplete Fix Modules (Zipped Tarball, 2.7K)

Installation

To install, first download and decompress the package. Either upload the whole autocomplete_fix folder to your site's modules folder, or just upload the individual module within the autocomplete_fix folder that you want to use. Go to your site's module admin page, enable one of the modules, and you're done. Autocomplete fields will now allow slashes, and behind the scenes they might even work in a smarter way...