Software engineer, data guy, Open Source enthusiast, New Hampshire resident, husband, father. Fan of guitars, hiking, photography, homebrewing, sarcasm.
Drupal 6: Creating an autocomplete field using the forms api and a menu callback
In this snippet, I’ll explain how to implement an autocompleting field using the forms API and a menu callback. The first thing you’ll need to create is the callback function that queries the database and returns an non-themed javascript result. In this function I’ll return a list of node IDs and their titles:
Next create a menu item:
Now if you flush your menu cache and go to your newly created menu path, you should see a list of nodeID and their titles formatted in JSON. Lastly, you’ll need to create the form element: