I may not have this quiet right but isn't this what hook_autocomplete is for? <a href="http://api.drupal.org/api/HEAD/function/user_autocomplete">http://api.drupal.org/api/HEAD/function/user_autocomplete</a><br><br>You can print drupal_to_js($my_array)? Mostly emailing a response because I would like to know the answer too.
<br><br><br><div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Date: Wed, 17 Jan 2007 17:43:10 -0800<br>From: Rob Thorne <
<a href="mailto:rob@torenware.com">rob@torenware.com</a>><br>Subject: [development] "Subclassing" the standard #autocomplete form<br> widget<br>To: <a href="mailto:development@drupal.org">development@drupal.org
</a><br>Message-ID: <<a href="mailto:45AED0AE.5060806@torenware.com">45AED0AE.5060806@torenware.com</a>><br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>I need a widget for Forms API which *almost* identical to the
<br>textfield autocomplete widget in 5.0. I want the same user experience<br>-- the user types and chooses an item. But I want the underlying AJAX<br>and Drupal behavior to differ a bit.<br><br>An example of the type of widget I'd want would be a "Country Selection"
<br>widget where what I really want is the two-character country code (US,<br>CA, GB, FR, and so on), but I want the user to think of typing "United<br>States", "Canada", "Great Britain", "France" or so on in order to get
<br>the popup to get set on this code.<br><br>Looking through the 5.0 sources, the way the current autocompletion<br>widget works is via includes/form.inc, where the theming function<br>theme_textfield($element) special cases textfields with the
<br>'#autocompletion_path' , by making sure that autocomplete.js gets added<br>to the page going out, and by adding a hidden <item> to store state<br>information that the code in autocomplete.js needs to do its work.
<br><br>I really don't need to change behavior very much; I just need to send<br>back an array of array(key, value), where the standard widget sends back<br>an array of string values. But pretty much everything else that
<br>Unconed's code does exactly what I want, and while I can copy if if<br>that's easiest, I don't want or need to change what he did.<br><br>What's the best way to create my modified Forms API widget? It looks
<br>like I'd want to "override" or "subclass" theme_textfield, although only<br>to add behavior: I don't want standard autocomplete widgets to behave<br>any different than usual (although I'd not want both sets of code to
<br>compete on the same widget). I'd then copy autocomplete.js and make<br>very small changes in it, changing function names where required.<br><br>Is there a better way to do this? Or even better, has someone else<br>
already done this?<br><br>Thanks,<br>Rob<br><br>Rob Thorne<br>Torenware Networks<br><br></blockquote></div>