Hi, I am writing a Drupal module for simple browser-based video editing. A user types a phrase into an textfield form element, which performs an autocomplete search to a table in the database for similar phrases. This part is easy, thanks to Drupal. But the hard part is that I need a second piece of information simultaneously extracted from the matched row in the database: The url to the media file.
My db structure:
The module creates table "colingo_media" with fields "title", "url", etc.
The issue wireframed:
1) I type "my name is p" into an autocomplete textfield.
2) The db is queried to look for all rows with title "my name is p" and returns "my name is phil" as the only possible match.
3) The user clicks on "my name is phil".
At this point, the URL for the matched row with title "my name is phil" needs to be returned to jQuery, where I'll add it as an attribute to the form element.
my precise question
How can I return multiple objects within the Drupal autocomplete framework, one as the item to be autocompleted, and the other as a hidden jQuery object?
the code i'm working with:
function colingo_autocomplete($string = '') {
$matches = array();
if ($string) {
$result = db_query_range("SELECT title FROM {colingo_media} WHERE LOWER(title) LIKE LOWER('%s%%')", $string, 0, 10);