Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

Getting a record id from text_field_with_auto_complete

Posted by Jim Morris on Mon Oct 23 13:58:46 -0700 2006

I ran into this problem a few times,and I have seen others asking the same question, if you use text_field_with_auto_complete and the selection list returns non-unique results, how do you reference the actual record in the database you want?

For instance if you have text_field_with_auto_complete :customer, :name then in your controller: name= params[:customer][:name] and Customer.find_all_by_name(name) returns more than one entry you need to be a little more tricky to retrieve the actual record you wanted to select.

... Show more ...

Posted in Rails  |  Tags rails,text_field_with_auto_complete  |  3 comments

Having multiple text_field_with_auto_complete in the same view

Posted by Jim Morris on Tue Oct 17 23:45:47 -0700 2006

I ran into a problem using text_field_with_auto_complete in a view where I wanted to have many of them created by an iteration. You can use the :index option for the text_field, but it doesn't carry over to the various divs used in the AJAX calls.

<typo:code lang="ruby"> <% 0.upto(10) do |legi| %> <% @leg= @mission.legs.find(:first, :conditions => ['legnum = ?', legi]) %> text_field_with_auto_complete( :leg, :name, {:index => legi, :size => 20}) <% end %> <% end %> </typo:code>

... Show more ...

Posted in Rails  |  Tags rails,text_field_with_auto_complete  |  18 comments