Autocomplete FAPI element

Component ID

1642534

Component name

Autocomplete FAPI element

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

Provides an autocomplete FAPI element, basically an enhanced version of a textfield with autocomplete, with the benefit of hiding away the real record ID. It allows the user to search and select an appropriate record as normal but uses a hidden field to store the selected record ID.

This module provides an autocomplete FAPI element which records the ID of the item selected during autocompletion so that it can be used during form submission to store the actual ID of the item, without needing to display the ID to the user.

This is in contrast to a normal textfield with autocomplete which simply stores the name of the autocomplete item and doesn't have the ID available unless it's stamped directly in the text shown to the user.

To achieve this it relies on javascript to populate the field in the normal way that a textfield with autocomplete does. If the user does not have javascript the field will still be displayed but rendered as disabled.

The module also contains a widgets module which currently supports node_reference and user_reference.

In writing this I search long and hard for anything which did this, and whilst I found many snippets of code which covered parts of this topic, nothing came close to my requirements of it a) just working, and b) doing it in a modular and reusable way.

Note that this is my first contribution to the drupal module world. I'm still digesting all of the drupal docs too, so please accept my apologies in advance if i've not completed something I should have in terms of Drupal best practise, i'll certainly fix it if so! Comments welcome.

Although this is currently a sandbox project, this is complete and should be fully working.