Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails : how to implement Cancel button in form_tag

I have a basic form using the form_tag helper working fine, but I want to add a cancel button, what is the syntax for doing this? I want the cancel button to appear as a button, not a link, then take the user to a different URL (indicating they don't want to submit the form).

TY, Fred

like image 684
fred basset Avatar asked Jan 14 '13 01:01

fred basset


1 Answers

If you mean a reset button, paste the following inside your form:

<%= button_tag "Reset", type: :reset %>

Tested it, it works fine and resets all fields in the form.

like image 193
weltschmerz Avatar answered Oct 07 '22 22:10

weltschmerz