I have a text field in a form, with autocomplete on. It works very well, but I cannot manage to find a way to highlight the letters in the suggested works. I found this hack in the autocomplete library (general, no Drupal related), but don't know if it applies or how to apply it. I would like the same effect:



Try Autocomplete Deluxe Module. May b this help you

| improve this answer | |
  • 1
    Thanks a lot, it works! However, I had to do the following, hacking the code, to make it work as I wanted: 1) delete the "the @term termi will be added" because it tried to add new non-existing content. 2) hack the code of *.js so it didn't trigger when mouse down or mouse up, just when I hit some key. 3) Add t() to the not found message. What I don't understand is that such a basic feature is not incorporated into the core autocomplete.js, and also don't understand why this module Autocomplete Deluxe is abandoned. – Cesar Sep 18 '15 at 10:41

I have found this tutorial. It is a small gem in which I have found the solution to this problem and this another one.

Basically, I use the hook callback function mymodule_formName_autocomplete ($type, $text) and there I can do drupal_json_output($output_string) where $output_string, based on the string query $text accepts any HTML label, so I can highlight at convenience by just using PHP, which is very powerful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.