I'm not sure it'll answer all your questions, but check out my article on the subject here...
http://blog.wolfman.com/articles/2006/10/23/getting-a-record-id-from-text_field_with_auto_complete
I hope it helps.
saizai wrote:
I'm not sure it'll answer all your questions, but check out my article on the subject here...
http://blog.wolfman.com/articles/2006/10/23/getting-a-record-id-from-text_field_with_auto_complete
I hope it helps.
saizai wrote:
Sai Emrys wrote:
Jim Morris wrote:
I'm not sure it'll answer all your questions, but check out my article on the subject here...
That sounds like the text field will display "23,foo,bar". Which is rather ugly.
The page you linked to just does the same thing - makes the first field 'id'; hides it in the dropdown but it'll be displayed as selected once something is chosen. Ugly UI. And then it uses that to populate other fields on the after-update call.
But I'd like a way to reliably populate a hidden field with the hidden 'id' part of the popup no matter how selected, and have the text field just show the prettified name.
Ok that link does hide the id, which is not the link it was meant to point to
Here is where the link should have pointed to...
http://wiki.rubyonrails.org/rails/pages/How+to+use+text_field_with_auto_complete/versions/67 about half way down, it has a nicer way to do it, but I have not tried that method.
There is another method here that uses javascript to write the id into a hidden_text field, I have used that method.
FYI I updated my blog with the correct links, and added two more ways of doing I found.
Jim Morris wrote: