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. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 11 May 2008, at 20:10, djlewis wrote:> > 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> Basically, I''m trying to implement a "Clear all data" button for a > bunch of pages. > > Thanks. --David. > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On May 11, 3:37 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 May 2008, at 20:10,djlewiswrote: > > > > > 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 > > > Basically, I''m trying to implement a "Clear all data" button for a > > bunch of pages. > > > Thanks. --David.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---