Start_form_tag n00b question


I’m wondering if there is any way to specify the id of a form tag with
start_form_tag helper. I’ve tried playing around with ",
id=>“marginForm” "
and also inclosing both the action variable and id variable in curley
brackets. The Rails API doesn’t off much help for a n00b like me. It’s
probably really easy but any help you guys can offer would really be


<%= form_tag :action => ‘update’, :id => “marginForm” %>

Note that you can find the answer by looking at <http://
FormTagHelper.html#M000491> and then following the
ActionController::Base#url_for link to <
classes/ActionController/Base.html#M000202>, where an example shows
the use of :id.

Also note that start_form_tag is an alias to form_tag.

        - dan

Dan K. mailto:[email protected] tel:+1-415-233-1000

Umm thanks but I don’t think I explained myself properly. What I would
it to generate is:

at the moment using what you suggested it generates:

I think I might to use an HTML helper or even use the url_for command that
you suggested, but I would prefer to use an actual Rails helper to
the entire form tag just so its easier to update and modify in the

" method="post" id="marginForm" >

Thanks for you help anyway. :slight_smile:


Chris Lloyd wrote:

Umm thanks but I don’t think I explained myself properly. What I would
it to generate is:

How about:

form_tag ({:action => ‘create’}, :id => ‘marginForm’)


Oh wow, thanks heaps. That works perfectly.

This might just be me not having much experience with either Ruby or
(coming from PHP), but I think that Ruby (with Rails) is the thinking
(or woman’s) language. If I put in 30 seconds thought about how I could
something in Rails I can do it in about 1/2 hour. Whereas you don’t
need to think at all with PHP but it’ll take you a day to code anything.

Thanks again Ian and Dan.



Chris - the problem you ran into is that often that you pass a helper
a hash, and sometimes you’ve got other hashes within that hash. If
there’s only one thing in each hash, you can pass them as a, b, c;
once you’re actually trying to pass in several, you need to delineate
the hashes: a, {b,d}, c

I still run into this every now and then. The API reference is always
good reference to show you what goes where, though.