# Add id to form\_tag?

**URL:** <https://www.ruby-forum.com/t/add-id-to-form-tag/93747>\
**Category:** Rails\
**Created:** [April 8, 2006, 10:13am UTC](https://www.ruby-forum.com/t/add-id-to-form-tag/93747 "2006-04-08T10:13:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 8, 2006, 10:13am UTC](https://www.ruby-forum.com/t/add-id-to-form-tag/93747/1 "2006-04-08T10:13:35Z")

</div>

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 C.man

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 8, 2006, 11:36am UTC](https://www.ruby-forum.com/t/add-id-to-form-tag/93747/2 "2006-04-08T11:36:38Z")

</div>

Jeff C.man 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 C.man

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

Hope this helps

p.s. Why GET and not POST?

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [April 8, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/add-id-to-form-tag/93747/3 "2006-04-08T19:08:46Z")

</div>

Chris T wrote:

> Jeff C.man 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 C.man
> 
> 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
> 
> 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
