eldarion / eldarion-ajax

a library for adding declarative ajax functionality to your website
BSD 3-Clause "New" or "Revised" License
758 stars 153 forks source link

Option NOT to clear form fields after submitting #19

Closed smartcorestudio closed 11 years ago

smartcorestudio commented 11 years ago

I think that clearing all form fields after submitting isn't the right decision. It should be optional. If we want to add many new items to the database autoclearing works perfect. But if we want to change info in users profile, for example, the fields shouldn't clear. Moreover, if we have any errors on the server side (wrong captcha-code, validation problrms, etc.) we want just to receive the error message without clearing the form.

paltman commented 11 years ago

@smartcorestudio I almost always replace the form with a rendered fragment from the server. This is typically either 1) a new form instance rendered in a template, 2) an invalid form instance rendered in a template with errors highlighted, or 3) replaced with some other content (like a success message).

I rather continue along the lines of this being a library handling content from the server and not getting too fancy on the client side. In fact, I am considering moving the form clear code out of this library all together. If you want to handle more activity client side that this library doesn't cover, I think you'll find the work that will come as a result of #17 useful. Where I'll supply enough events for developers to write their own custom client side logic.