hi all i was wondering whether it is possible to use partials along with form_for and form_field. following code is not working. is there some error or this case is impossible..?? *#new.html.erb* <h1>Enter Details for new Partner:</h1> <% form_for(@partner) do |f| %> <%= render :partial => ''form'', :locals => {:partner => f} %> <p> <%= f.submit "Create" %> </p> <% end %> *#_form.html.erb* <%= f.error_messages %> <p> <%= f.label :organisations_id, "Organisation Id" %><br /> <%= f.text_field :organisations_id %> </p> <p> <%= f.label :branches_id, "Branch Id" %><br /> <%= f.text_field :branches_id %> </p> regards -- Sahil --~--~---------~--~----~------------~-------~--~----~ 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 6 Feb 2009, at 10:06, Sahil Dave wrote:> hi all > > i was wondering whether it is possible to use partials along with > form_for and form_field. following code is not working. is there > some error or this case is impossible..?? >You need to pass the form builder object to the partial (eg via locals). You are passing it, but then you''re not using it, so if you change your partial to use partner.error_messages etc... it should work. Alternatively you could just do <%= render :partial => f%> Because f is a FormBuilder this will render the partial _form and will set the local variable form to be the form builder (so you''ll need to use form.error_messages etc...). Fred> #new.html.erb > > <h1>Enter Details for new Partner:</h1> > > <% form_for(@partner) do |f| %> > <%= render :partial => ''form'', :locals => {:partner => f} %> > > <p> > <%= f.submit "Create" %> > </p> > <% end %> > > #_form.html.erb > > <%= f.error_messages %> > > <p> > <%= f.label :organisations_id, "Organisation Id" %><br /> > <%= f.text_field :organisations_id %> > </p> > <p> > <%= f.label :branches_id, "Branch Id" %><br /> > <%= f.text_field :branches_id %> > </p> > > > regards > -- > Sahil > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Feb 6, 3:35 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You need to pass the form builder object to the partial (eg via > locals). You are passing it, but then you''re not using it, so if you > change your partial to use partner.error_messages etc... it should work. > > Alternatively you could just do > > <%= render :partial => f%> > > Because f is a FormBuilder this will render the partial _form and will > set the local variable form to be the form builder (so you''ll need to > use form.error_messages etc...).thanks for the help Frederick. i got it. but how do i get the value entered in a partial form..? like i have an ''address'' partial that i am rendering in a ''user'' view. then how do i retrieve the values entered in partial in the ''user'' controller? specifically which ''param'' symbol? --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---