Implement "Clear form"

What's a good way to clear all the fields a form that can apply generally to any form (so I can write one method and apply it to any one of a set of forms). If that can't be done with a form (say because I can't know programmatically what field are in a form) I'd be content to simply clear all the attributes in a record and ship that to the form.

Basically, I'm trying to implement a "Clear all data" button for a bunch of pages.

Thanks. --David.

What's a good way to clear all the fields a form that can apply generally to any form (so I can write one method and apply it to any one of a set of forms). If that can't be done with a form (say because I can't know programmatically what field are in a form) I'd be content to simply clear all the attributes in a record and ship that to the form.

With javascript you can call the form's reset method or you can have a
reset button ( <input type="reset" value="Reset!">)

Fred

I just realized that, in response to the "clear" button submit, simply issuing "render" in the controller clears all the fields, as long as there is no @record_instance present. Is that legit -- any downsides?

(Not long ago, I was trying to evade this behavior. Now it's the solution to a problem!)

Another way I though of is to go through params[:record_instance] for the names of the most recently submitted form's fields, set each those to blank and then render. Didn't get to test that yet, however, since having no @record_instance at all seems to do the trick.

--David