Autocomplete For A "Select" Widget
I'm looking at using autocomplete for contacts stored in CiviCRM. Implementing basic autocomplete using the standard Drupal hook was pretty simple: just search the CRM store for a contacts "display name" via the autocomplete handler. But there's a problem with how the standard handler works: display names are not unique. What I probably *need* to do is this: use the autocomplete field to populate a "select" widget that uses the display name as the label, and the unique numerical contact_id as the key. Before I start looking into implementing this myself: have any of you implemented this kind of widget? Or do you have advice how best to do this? Thanks, Rob Rob Thorne Torenware Networks http://www.torenware.com
Rob Thorne wrote:
I'm looking at using autocomplete for contacts stored in CiviCRM. Implementing basic autocomplete using the standard Drupal hook was pretty simple: just search the CRM store for a contacts "display name" via the autocomplete handler.
But there's a problem with how the standard handler works: display names are not unique. What I probably *need* to do is this: use the autocomplete field to populate a "select" widget that uses the display name as the label, and the unique numerical contact_id as the key.
Before I start looking into implementing this myself: have any of you implemented this kind of widget? Or do you have advice how best to do this?
It's not *exactly* similar but I posted a two-step autocomplete example here: http://drupal.org/node/50073 In your case I'd probably use 'onclick' on the selected name and then build/write the SELECT using the clicked name as a WHERE clause if the DB has >1 results -- ------------------------------------------- John Handelaar E john@handelaar.org T +353 21 427 9033 M +353 85 748 3790 http://handelaar.org -------------------------------------------
Rob, you would be able to use my activeforms module to make a two-widget autocomplete form. I imagine it would be a text field and a select and they keep each other synchronized. You can read about my module on the groups site. It lets you write server-side code to attach event listeners to client-side DOM objects. http://groups.drupal.org/node/317 Cheers, Robert Rob Thorne wrote:
I'm looking at using autocomplete for contacts stored in CiviCRM. Implementing basic autocomplete using the standard Drupal hook was pretty simple: just search the CRM store for a contacts "display name" via the autocomplete handler.
But there's a problem with how the standard handler works: display names are not unique. What I probably *need* to do is this: use the autocomplete field to populate a "select" widget that uses the display name as the label, and the unique numerical contact_id as the key.
Before I start looking into implementing this myself: have any of you implemented this kind of widget? Or do you have advice how best to do this?
Thanks, Rob
Rob Thorne Torenware Networks http://www.torenware.com
participants (3)
-
John Handelaar -
Rob Thorne -
Robert Douglass