Making a form reset button in Rails

Tags: 

Rails doesn't have reset_tag to automatically make a form reset button, instead you have to take a slightly different route. To make a form reset button in Rails you simply do this:
[source:ruby]
< %= submit_tag("Start Over", { :name => 'reset', :id => 'reset_button', :type => "reset" }) %>
[/source]
which will create the following:
[source:html]

[/source]
The important part here is the :type argument, which override's Rails' default of "submit" for the submit_tag. Then, to tidy it up a little I override the :name, which defaults to "commit", and give it a useful id attribute.

Et voila!

How to reply

Care to add your own 2 cents? Let me know via Twitter or my contact page.