Forum: Ruby on Rails Add id to form_tag?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-08 10:13
Hi all,

What is the correct syntax to add an id attribute to a form tag with the
"form_tag" helper?

I've tried

start_form_tag({:controller => 'houses', :action => 'find'}, {:method =>
:get, :id => 'search'})

start_form_tag({:controller => 'houses', :action => 'find'}, :method =>
:get, :id => 'search')

And other variations, but so far it doesn't give the form the attribute.
Can it be done?

Thanks,
Jeff Coleman
58c6efb8466b9f85155fe6aa9fc37fce?d=identicon&s=25 Chris T (Guest)
on 2006-04-08 11:36
(Received via mailing list)
Jeff Coleman wrote:
> start_form_tag({:controller => 'houses', :action => 'find'}, :method =>
> :get, :id => 'search')
>
> And other variations, but so far it doesn't give the form the attribute.
> Can it be done?
>
> Thanks,
> Jeff Coleman
>
>
Not sure if I'm understanding what you're trying here but try:

start_form_tag({:controller => 'houses', :action => 'find', :id
=>'search'}, {:method => :get})
generates
<form action="/houses/find/search" method="get">
Hope this helps

p.s. Why GET and not POST?
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-08 19:08
Chris T wrote:
> Jeff Coleman wrote:
>> start_form_tag({:controller => 'houses', :action => 'find'}, :method =>
>> :get, :id => 'search')
>>
>> And other variations, but so far it doesn't give the form the attribute.
>> Can it be done?
>>
>> Thanks,
>> Jeff Coleman
>>
>>
> Not sure if I'm understanding what you're trying here but try:
>
> start_form_tag({:controller => 'houses', :action => 'find', :id
> =>'search'}, {:method => :get})
> generates
> <form action="/houses/find/search" method="get">
> Hope this helps
>
> p.s. Why GET and not POST?

Thanks, Chris.  I was making a silly mistake--when I checked in my code,
I was looking at the wrong form tag, and thinking the "id" tag wasn't
working.

"Get"'s used here because it's a non-destructive search operation and I
want people to be able to bookmark or go back to the results page.

Jeff
This topic is locked and can not be replied to.