# Multiple forms on a page

**URL:** <https://www.ruby-forum.com/t/multiple-forms-on-a-page/73982>\
**Category:** Rails\
**Created:** [February 27, 2006, 4:35am UTC](https://www.ruby-forum.com/t/multiple-forms-on-a-page/73982 "2006-02-27T04:35:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [February 27, 2006, 4:35am UTC](https://www.ruby-forum.com/t/multiple-forms-on-a-page/73982/1 "2006-02-27T04:35:21Z")

</div>

Hello all.

I have the following Code in a view:

\<% @dishes.each do |dish| -%\>

\<%= link\_to dish.name, :controller =\> "restaurant", :action =\> "show\_dish", :id =\>"#{dish.id}" -%\> \<% if dish.vegetarian? -%\> \<%= image\_tag("/images/vegetarian.gif", :class =\> "bevel", :size =\> "8x8") %\> \<% end -%\> \<%=h dish.summary -%\> \<%=h dish.price -%\> \<%= form\_tag :action =\> :add\_to\_trolley -%\> \<%= hidden\_field\_tag("id", "#{dish.id}") -%\>\<%= text\_field\_tag("fresh","", :size =\> "2", :value =\> "0" ) -%\> \<%= text\_field\_tag("frozen","", :size =\> "2", :value =\> "0") -%\> \<%= submit\_tag("Order") -%\> \<% end\_form\_tag -%\> \<% end -%\>

The idea is to present the user with a list of orderlines with an  
“Order” button at the end of each line. They fill in the “Fresh” and  
“Frozen” values for a line and hit that line’s order button.

What appears to be happening is that the submit button for every line  
tries to submit the data in the “Fresh” and “Frozen” values for the  
first line ONLY instead of the line in which the order button is part  
of. Can anyone see why?

Thanks

Jeff

---

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [February 27, 2006, 6:26am UTC](https://www.ruby-forum.com/t/multiple-forms-on-a-page/73982/2 "2006-02-27T06:26:10Z")

</div>

Have you looked at the html source that is outputted by rails? Can you  
post it here? That should give some insight into what’s getting posted,  
etc.

---

<div class="post-metadata">

**Author:** ![jjantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dfb087/32.png) [@jjantz](https://www.ruby-forum.com/u/jjantz)\
**Post date:** [February 27, 2006, 6:28am UTC](https://www.ruby-forum.com/t/multiple-forms-on-a-page/73982/3 "2006-02-27T06:28:35Z")

</div>

> \<%=h dish.price -%\> \<%= form\_tag :action =\> :add\_to\_trolley -%\> \<%= hidden\_field\_tag("id", "#{dish.id}") -%\>\<%= 
> 
> > \<%= submit\_tag("Order") -%\> \<% end\_form\_tag -%\> \<% end -%\>
> 
> Hmm… just a guess, but it could be because your form tag isn’t  
> actually in the table. Trying putting the whole form inside a
> 
> .  
> Yes, that might give you problems with formatting, but you could  
> probably use CSS to fix that: form { display:inline; }
