# Form\_tag and button\_to bug?

**URL:** <https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342>\
**Category:** Rails\
**Created:** [August 5, 2011, 11:04am UTC](https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342 "2011-08-05T11:04:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [August 5, 2011, 11:04am UTC](https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342/1 "2011-08-05T11:04:54Z")

</div>

Hi,everyone:  
I use form\_tag create a form and nested a button\_to tag like this:  
\<%= form\_tag(orders\_path) do %\>  
… #some form fields  
\<%=button\_to “remove”,line\_item, :method=\>:delete  
%\>  
\<%= submit\_tag “Checkout” %\>  
\<% end %\>

when I click “Checkout” ,the form always invokes “remove” method!  
How can I solve this problem? Thanks!

---

<div class="post-metadata">

**Author:** ![ryman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@ryman](https://www.ruby-forum.com/u/ryman)\
**Post date:** [August 5, 2011, 11:33am UTC](https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342/2 "2011-08-05T11:33:20Z")

</div>

On 5 August 2011 05:10, ryman [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How can I solve this problem? Thanks!  
> Have a look at the html of the page (View \> Page Source, or similar,  
> in the browser) and see what tag you are generating. That will  
> show you what action should be called. Also you can look in  
> log/development.log to see what it says when you click submit.

Unless you have a good reason, however, I would suggest using form\_for  
rather than form\_tag. It makes life easier generally.

Colin

---

<div class="post-metadata">

**Author:** ![ryman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@ryman](https://www.ruby-forum.com/u/ryman)\
**Post date:** [August 5, 2011, 11:51am UTC](https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342/3 "2011-08-05T11:51:14Z")

</div>

On Fri, Aug 5, 2011 at 12:10 PM, ryman [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,everyone:  
> I use form\_tag create a form and nested a button\_to tag like this:  
> \<%= form\_tag(orders\_path) do %\>  
> … #some form fields  
> \<%=button\_to “remove”,line\_item, :method=\>:delete  
> %\>  
> \<%= submit\_tag “Checkout” %\>  
> \<% end %\>

I’m not sure but I think button\_to creates a form. Since button\_to is  
inside  
the form tag, and it creates a form, then clicking ‘Checkout’ will also  
submit  
whatever is inside the form created by button\_to.

> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–

---

<div class="post-metadata">

**Author:** ![ryman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@ryman](https://www.ruby-forum.com/u/ryman)\
**Post date:** [August 5, 2011, 12:43pm UTC](https://www.ruby-forum.com/t/form-tag-and-button-to-bug/210342/4 "2011-08-05T12:43:12Z")

</div>

On 5 August 2011 10:47, Jim Ruther N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > ```
> > <%= submit_tag "Checkout" %>
> > <% end %>
> > 
> > ```
> 
> I’m not sure but I think button\_to creates a form. Since button\_to is  
> inside  
> the form tag, and it creates a form, then clicking ‘Checkout’ will also  
> submit  
> whatever is inside the form created by button\_to.

Yes of course, good thinking Jim. Nested forms are not allowed in html.

Colin
