Start_form_tag n00b question

Hi,

I’m wondering if there is any way to specify the id of a form tag with
the
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
appreciated.

Chris

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

Note that you can find the answer by looking at <http://
api.rubyonrails.com/classes/ActionView/Helpers/
FormTagHelper.html#M000491> and then following the
ActionController::Base#url_for link to <http://api.rubyonrails.com/
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]
http://www.dankohn.com/ tel:+1-415-233-1000

Umm thanks but I don’t think I explained myself properly. What I would
like
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
construct
the entire form tag just so its easier to update and modify in the
future.

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

Thanks for you help anyway. :slight_smile:

Chris

Chris Lloyd wrote:

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

How about:

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

Ian.

Oh wow, thanks heaps. That works perfectly.

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

Thanks again Ian and Dan.

Regards,

Chris

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs