I may not have this quiet right but isn&#39;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 &lt;
<a href="mailto:rob@torenware.com">rob@torenware.com</a>&gt;<br>Subject: [development] &quot;Subclassing&quot; the standard #autocomplete form<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;widget<br>To: <a href="mailto:development@drupal.org">development@drupal.org
</a><br>Message-ID: &lt;<a href="mailto:45AED0AE.5060806@torenware.com">45AED0AE.5060806@torenware.com</a>&gt;<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.&nbsp;&nbsp;I want the same user experience<br>-- the user types and chooses an item.&nbsp;&nbsp;But I want the underlying AJAX<br>and Drupal behavior to differ a bit.<br><br>An example of the type of widget I&#39;d want would be a &quot;Country Selection&quot;
<br>widget where what I really want is the two-character country code (US,<br>CA, GB, FR, and so on),&nbsp;&nbsp;but I want the user to think of typing &quot;United<br>States&quot;,&nbsp;&nbsp;&quot;Canada&quot;, &quot;Great Britain&quot;, &quot;France&quot; or so on in order to get
<br>the popup&nbsp;&nbsp;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,&nbsp;&nbsp;where the theming function<br>theme_textfield($element)&nbsp;&nbsp;special cases textfields with the
<br>&#39;#autocompletion_path&#39; ,&nbsp;&nbsp;by making sure that autocomplete.js gets added<br>to the page going out,&nbsp;&nbsp;and by adding a hidden &lt;item&gt; to store state<br>information that the code in autocomplete.js needs to do its work.
<br><br>I really don&#39;t need to change behavior very much;&nbsp;&nbsp;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.&nbsp;&nbsp;But pretty much everything else that
<br>Unconed&#39;s code does exactly what I want, and while I can copy if if<br>that&#39;s easiest, I don&#39;t want or need to change what he did.<br><br>What&#39;s the best way to create my modified Forms API widget?&nbsp;&nbsp;It looks
<br>like I&#39;d want to &quot;override&quot; or &quot;subclass&quot; theme_textfield, although only<br>to add behavior:&nbsp;&nbsp;I don&#39;t want standard autocomplete widgets to behave<br>any different than usual (although I&#39;d not want both sets of code to
<br>compete on the same widget).&nbsp;&nbsp;I&#39;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?&nbsp;&nbsp;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>