Forum: Ruby on Rails FormTagHelper form names: possible?

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.
Sean C. (Guest)
on 2006-04-05 11:31
Thank you to everybody that has helped me since I signed up. I'm flying
along thanks to you.

I have a question about the FormTagHelper "start_form_tag": I've been
trying to figure out how to get Rails to output a "name" attribute for
my form so I can hook in a Javascript to focus on a field inside of it
on load, but it doesn't look like I can do it. I'm not sure how to read
the API; it doesn't have any examples. Everything I put into the command
just appends information to the action after a question mark or gives me
an error. I've tried putting name="myformname" into double quotes,
single quotes, curly braces, brackets, you name it, but nothing works.
I'm beginning to think I should just code it in with HTML and forget
using the FormTagHelpers for form declarations entirely if I need any
attributes except "action" and "method".

Anybody know if I'm right or wrong here?
Rimantas L. (Guest)
on 2006-04-05 13:32
(Received via mailing list)
> I have a question about the FormTagHelper "start_form_tag": I've been
> trying to figure out how to get Rails to output a "name" attribute for
> my form so I can hook in a Javascript to focus on a field inside of it
> on load, but it doesn't look like I can do it. I'm not sure how to read
> the API; it doesn't have any examples. Everything I put into the command
> just appends information to the action after a question mark or gives me
> an error.
<...>
> Anybody know if I'm right or wrong here?

start_form_tag accepts two hashes - one for url_for and second one for
html options, so
you must explicitly separate them with {}.

This should work:

<%= form_tag(  {:action => :my_action}, {:name => :my_form} ) %>

Regards,
Rimantas
--
http://rimantas.com/
This topic is locked and can not be replied to.