Hi, I''ve created some a form for filling some signup information for an user. Now i need to reuse the same code to create an ''edit information'' form, what means that the forms needs to be initialized with the values stored in the database. I suppose there is some automatic mean of doing such, but can''t find no information on this topic. Thanks in advance, hugo --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hpacheco wrote:> Hi, > > I''ve created some a form for filling some signup information for an > user. > > Now i need to reuse the same code to create an ''edit information'' > form, what means that the forms needs to be initialized with the > values stored in the database. > > I suppose there is some automatic mean of doing such, but can''t find > no information on this topic. > > Thanks in advance, > hugoTry to look at scaffold, they do that and you can learn from it :) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5/26/07, hpacheco <hpacheco-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''ve created some a form for filling some signup information for an > user. > > Now i need to reuse the same code to create an ''edit information'' > form, what means that the forms needs to be initialized with the > values stored in the database. > > I suppose there is some automatic mean of doing such, but can''t find > no information on this topic. > > Thanks in advance, > hugoThere are 2 basic types of form helpers: the form helpers and the form tag helpers. The form tag helpers are basic wrappers around input tags. <%= text_field_tag :search, params[:search] %> Form helpers work with objects: <%= text_field ''user'', ''name'' %> This will prefill with the value from @user.name, and set a form name of "user[name]". form_for gives you a nice shortcut for this: <% form_for :user do |form| -%> <%= form.text_field :name %> <%= form.text_field :email %> <% end -%> -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---