James Bond wrote:
> If I have table user (id, firstname, lastname, age, city)
> 
> And form: textboxes for firstname, lastname, age and select for city
> 
> Is it possible to auto complete form? Not only firstname or lastname,
> but full form?
> So if I enter lastname, and there is only one user with this name, so it
> auto complete firstname, age and city.

Hello there,
Why don't you try a form_observer to do the job?

Simple example:
(view)
<% form_for :foo, :id => "my_form" %>
   <%= form.text_field :first_name%>
   <%= form.text_field :last_name%>
   <%= form.text_field :age%>
<% end %>
<%= observe_form :my_form, :frequency => 0.5, :url => {:action => 
search_result" } %>

(controller)
def search_result
   @foo = User.find(:all, :conditions => ["first_name LIKE ?, last_name 
LIKE ?",params[:first_name], params[:last_name]])
   render view again
end


I don't now if what you want to do is a good idea, but.... that is the 
way I'll do it (what does not mean that is the best way, I'm new in 
Rails).

David Sousa



-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to