Form_for() and name

how can i give name attributes for form_for(), so it will give an output
like . 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 :slight_smile:

On 10/13/06, Adrian L. [email protected] wrote:

: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 :slight_smile:

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 O.
http://weblog.techno-weenie.net
http://mephistoblog.com

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! :slight_smile:

Rick O. 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 O.
http://weblog.techno-weenie.net
http://mephistoblog.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs