# Start\_form\_tag n00b question

**URL:** <https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044>\
**Category:** Rails\
**Created:** [July 12, 2006, 5:27am UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044 "2006-07-12T05:27:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 5:27am UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/1 "2006-07-12T05:27:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 7:18am UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/2 "2006-07-12T07:18:03Z")

</div>

\<%= form\_tag :action =\> ‘update’, :id =\> “marginForm” %\>

Note that you can find the answer by looking at \<http://  
[api.rubyonrails.com/classes/ActionView/Helpers/](http://api.rubyonrails.com/classes/ActionView/Helpers/)  
FormTagHelper.html#M000491\> and then following the  
ActionController::Base#url\_for link to \<[http://api.rubyonrails.com/](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:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.dankohn.com/](http://www.dankohn.com/)tel:+1-415-233-1000

---

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 11:34am UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/3 "2006-07-12T11:34:12Z")

</div>

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. 🙂

Chris

---

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 1:51pm UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/4 "2006-07-12T13:51:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 2:27pm UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/5 "2006-07-12T14:27:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chris\_Lloyd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/cab0a1/32.png) [@Chris\_Lloyd](https://www.ruby-forum.com/u/Chris_Lloyd)\
**Post date:** [July 12, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/start-form-tag-n00b-question/98044/6 "2006-07-12T15:59:56Z")

</div>

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.
