# Specifying a Form name using start\_/form\_tag

**URL:** <https://www.ruby-forum.com/t/specifying-a-form-name-using-start-form-tag/62708>\
**Category:** Rails\
**Created:** [June 7, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/specifying-a-form-name-using-start-form-tag/62708 "2006-06-07T14:40:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Xenakis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@Michael\_Xenakis](https://www.ruby-forum.com/u/Michael_Xenakis)\
**Post date:** [June 7, 2006, 2:40pm UTC](https://www.ruby-forum.com/t/specifying-a-form-name-using-start-form-tag/62708/1 "2006-06-07T14:40:01Z")

</div>

Hey all.

I’m trying use the form tag(s) to create a named / id’d form. I.e.,  
I need to use JS to access the form via the DOM and submit it -  
support for a reusable navigation component which will persist app  
state on each jump.

However, from reading the form\_tag APIs and searching google, I don’t  
see where either :name or :id is an option which can be passed into  
the form\* tags. And having tried a number of permutations for  
specifying the additional parameter based on the conventions for  
other tags all result in error.

Any thoughts?

Thanks much,  
mx.

Michael Xenakis  
Architect  
Ã?bermind, Inc.  
206.290.3362  
removed\_email\_address@domain.invalid  
[http://www.ubermind.com](http://www.ubermind.com)

---

<div class="post-metadata">

**Author:** ![Michael\_Xenakis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@Michael\_Xenakis](https://www.ruby-forum.com/u/Michael_Xenakis)\
**Post date:** [June 8, 2007, 10:34pm UTC](https://www.ruby-forum.com/t/specifying-a-form-name-using-start-form-tag/62708/2 "2007-06-08T22:34:33Z")

</div>

I struggled with this same problem for a while. The issue, as you say,  
is how to specify the DOM id of a form when using the form\_tag method.  
This is helpful when using things like ‘observe\_form’, which requires  
the form’s ID.

Try this:

\<%= form\_tag( {:action=\>‘xyz’}, {:id=\>‘my\_form\_id’} ) %\>

\*\*\* The key is to surround your arguments with parenthesis. \*\*\*

I could swear that passing multiple hashes without surrounding parens  
works in many other methods, so I’m not sure why it’s a problem here.

I hope this helps anyone who’s struggled with this.

-Ben Ridout

---

<div class="post-metadata">

**Author:** ![Michael\_Xenakis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@Michael\_Xenakis](https://www.ruby-forum.com/u/Michael_Xenakis)\
**Post date:** [July 9, 2007, 9:29pm UTC](https://www.ruby-forum.com/t/specifying-a-form-name-using-start-form-tag/62708/3 "2007-07-09T21:29:43Z")

</div>

Ruby doesn’t know if it’s a hash or a block - that’s why you need  
parentheses. ie:

foo.bar { … }

the intent of the braces is ambiguous (and is most likely a block),  
but

foo.bar( { … } )

clearly is taking a hash as an argument.

On Jun 8, 4:34 pm, Bne R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
