Dynamic Form Validation in Symfony using Ajax

Symfony has a great form validation system. The only downside is that it requires the form to be submitted in order to check for any constraint violations. And sometimes, that means that user experience will suffer. And other times, a form submission only for error detection is just not possible. For example, I like to open small forms in modal windows. In this case, submitting the form means closing the modal. And detecting the error and re-opening the same modal with the new information is a painful process. In order to handle all these cases elegantly, I have a small Ajax routine which dynamically checks form constraints while the user completes the form. I still have server-side Symfony validation in place, because one can easily get around JavaScript verification. Read More