HTML class or id for form_tag's

I need my forms to have HTML id or class but seems there is not such
parameter in form_tag or form_tag_for. At least not in the rails doc.
I’ve been searching for a while and I couldn’t find a workarround
without pure HTML or gsub! which wouldn’t be pretty.

Thanks.

Macario O. wrote:

I need my forms to have HTML id or class but seems there is not such
parameter in form_tag or form_tag_for. At least not in the rails doc.
I’ve been searching for a while and I couldn’t find a workarround
without pure HTML or gsub! which wouldn’t be pretty.

Thanks.

in

http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000607

is written

form_tag(’/posts/1’, :method => :put)

output -

so, try doing (untested)

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

and u should be good.
hth

so, try doing (untested)

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

oops, i meant

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

:slight_smile:

Shai R. wrote:

so, try doing (untested)

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

oops, i meant

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

:slight_smile:

Thaks for the quick reply. I’ve tried this with form_remote:

<% form_remote_for( :comentario, :url => comentario_path(@comentario),
:html => { :method => :put }, :update => @id.to_s, :id => :fade_out ) do
|f| %>

and this

<% form_remote_for( :comentario, :url => comentario_path(@comentario),
:html => { :method => :put, :id => :fade_out }, :update => @id.to_s, )
do |f| %>

and doesn’t work

you should be able to specify the html id and class for every rendered
element. Any workarround for form_remote_for, link_to_remote or every
other element?

appending gsub!(/^(<.*) /, ‘</1 id=“wathever”’ or something similar to
the expression return should do but doesn’t looks too good.

Shai R. wrote:

so, try doing (untested)

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

oops, i meant

form_tag(’/posts/1’, :id => :id_name, :class=> :class_name )

output -

:slight_smile:

Yep, you where right, sorry. This works:

:html => { :method => :put, :style => “float:right;”}

thanks