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! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 August 2011 05:10, ryman <liurui81-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 %> > > when I click "Checkout" ,the form always invokes "remove" method! > 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 <form> 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Aug 5, 2011 at 12:10 PM, ryman <liurui81-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.> when I click "Checkout" ,the form always invokes "remove" method! > How can I solve this problem? Thanks! > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 5 August 2011 10:47, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Fri, Aug 5, 2011 at 12:10 PM, ryman <liurui81-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.Yes of course, good thinking Jim. Nested forms are not allowed in html. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.