# Multiple form\_tag on page

**URL:** <https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765>\
**Category:** Rails\
**Created:** [January 22, 2008, 12:49am UTC](https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765 "2008-01-22T00:49:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toshach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@toshach](https://www.ruby-forum.com/u/toshach)\
**Post date:** [January 22, 2008, 12:49am UTC](https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765/1 "2008-01-22T00:49:58Z")

</div>

Hi… new to the whole Rails thing so this may sound aweful strange  
but I cannot find any documentation supporting or correcting what I am  
trying to do…

I would like to have 2 separate form\_tag’s displayed on a single  
page. They both have varying function so my thinking is 2 separate  
form\_tag’s (am I wrong).

My problem is when the page renders it only renders 1 form but housing  
the varu=ious components of each form\_tag (eg. input boxes, submit  
button etc). There are 2 submit buttons for each of the functions Im  
wanting to perfom but because they are caught up under the one  
form\_tag, it doesnt matter which one I press, only the one action is  
ever performed…

As mentioned, very new so not sure what I should be doing…

\<%= form\_tag(:controller =\> ‘public’, :action =\> ‘send\_login’) %\>  
\<%= error\_messages\_for ‘user’ %\>

  
  
  
  
  
  
  
  
  
  
  
  
  

| user name : | \<%= text\_field(:user, :username) %\> |
| password : | \<%= password\_field(:user, :password) %\> |
| | \<%= submit\_tag(‘Login’) %\> | \<%= link\_to(‘new  
venue’, :controller =\> ‘venue’, :action =\> ‘new’) %\> |

  
\<%= form\_tag %\>

```
<h2>Commenter Login</h2>

<%= form_tag('send_feedback', :controller => 'public', :action =>

```

‘send\_fedback’) %\>  
\<%= error\_messages\_for ‘temp’ %\>

  
  
  
  
  
  
  
  
  

| venue code : | \<%= text\_field(:comments, :restaurant\_id) %\> |
| | \<%= submit\_tag(‘Feedback’) %\> |

  
\<%= form\_tag %\>

---

<div class="post-metadata">

**Author:** ![toshach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@toshach](https://www.ruby-forum.com/u/toshach)\
**Post date:** [January 22, 2008, 1:24am UTC](https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765/2 "2008-01-22T01:24:28Z")

</div>

I should have added…

Using Rails 2.0.2. I know this works with previous versions with the  
start\_form\_tag and end\_form\_tag as I have seen code that does this.  
However, with 2.0+, this seems to have gone the way of the dodo and I  
cannot figure out a way of doing it…

And clearly these form\_tag’s are NOT nested as I know HTML does not  
support this. My gut feel is this should be something simple and I am  
just missing something very basic…

---

<div class="post-metadata">

**Author:** ![toshach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@toshach](https://www.ruby-forum.com/u/toshach)\
**Post date:** [January 22, 2008, 1:44am UTC](https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765/3 "2008-01-22T01:44:56Z")

</div>

2 things:

1. You need to ‘end’ the form\_tag.
2. Blocks (that is, when there’s a ‘do’ and an ‘end’) no longer have  
“=” in the Erb tags.

In other words:

\<% form\_tag do %\>  
…  
\<% end %\>

Always check out [http://api.rubyonrails.com](http://api.rubyonrails.com) and search for the method  
you’re having trouble with

---

<div class="post-metadata">

**Author:** ![toshach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@toshach](https://www.ruby-forum.com/u/toshach)\
**Post date:** [January 22, 2008, 3:28am UTC](https://www.ruby-forum.com/t/multiple-form-tag-on-page/126765/4 "2008-01-22T03:28:26Z")

</div>

Ahh - that was so simple - thank you very much…

I did look through the api documentation but admittedly was manically  
skimming it instead of taking it in and must have overlooked that  
pesky little ‘=’ sign

On Jan 22, 11:44 am, “removed\_email\_address@domain.invalid”
