how can i give name attributes for form_for(), so it will give an output like <form name="f">. it is because that i need to access the form name for javascript manipulation. as far as i know, name can only used in form_tag(), but i currently have more than 50 forms that built using form_for(). the structure is like this: <% form_for symbol, item, :url => { :action => "do_update", :id => item } do |f| -%> <%= f.text_field(:title)] %> <%= f.text_field(:price)] %> <%= submit_tag ''Save'' -%> <% end -%> in case i have to change to form_tag(), is there any structure suggestion to change my form_for() to form_tag() ? thanks in advance, any inputs will help :) -- 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 -~----------~----~----~----~------~----~------~--~---
On 10/13/06, Adrian Liem <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > how can i give name attributes for form_for(), so it will give an output > like <form name="f">. it is because that i need to access the form name > for javascript manipulation. > > as far as i know, name can only used in form_tag(), but i currently have > more than 50 forms that built using form_for(). the structure is like > this: > > <% form_for symbol, item, > :url => { :action => "do_update", :id => item } do |f| -%> > <%= f.text_field(:title)] %> > <%= f.text_field(:price)] %> > <%= submit_tag ''Save'' -%> > <% end -%> > > in case i have to change to form_tag(), is there any structure > suggestion to change my form_for() to form_tag() ? > > thanks in advance, any inputs will help :)http://rails.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000387 Html attributes for the form tag can be given as :html => {…}. Example: <% form_for :person, @person, :html => {:id => ''person_form'', :name => ''foo''} do |f| %> ... <% end %> -- Rick Olson 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
thanks it works! i changed the :url into :html and it works i''ve read the API again and again but somehow i missed the html name attributes part. you don''t know how much it has help me.. again, many thanks! :) Rick Olson wrote:> Html attributes for the form tag can be given as :html => {�}. Example: > > <% form_for :person, @person, :html => {:id => ''person_form'', :name > => ''foo''} do |f| %> > ... > <% end %> > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com-- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---