Forum: Ruby on Rails Specifying a Form name using start_/form_tag

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3aa83129a45100f9130a2c221b467e95?d=identicon&s=25 Michael Xenakis (Guest)
on 2006-06-07 14:40
(Received via mailing list)
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,

Michael Xenakis
Ã?bermind, Inc.
0b76a7b65c503f6741774ee489af6535?d=identicon&s=25 Bne Ridout (Guest)
on 2007-06-08 22:34
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
1263ae66d745b45e8efb88dd668a7ce0?d=identicon&s=25 YodaYid (Guest)
on 2007-07-09 21:29
(Received via mailing list)
Ruby doesn't know if it's a hash or a block - that's why you need
parentheses.  ie: { .... }

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

clearly is taking a hash as an argument.

On Jun 8, 4:34 pm, Bne Ridout <>
This topic is locked and can not be replied to.