Search code examples
zend-frameworkzend-formzend-form-element

zend framework - how not to wait for upload if some validator fails?


i have a form with various elements and a file upload, sometimes the user has to wait for the upload to finish only to see he wrote something wrong(some element didn't pass validation).

Is it possible that if some validator fails on any element of the form, all other validation stops and the form returns immediately without waiting for the upload to finish ?


Solution

  • Yes, of course.

    • Use Javascript validation in addition to server side validation (never use only js validation). With Javascript validation you can give the user feedback instantly, even while filling in a particular form field.
    • Break the Zend_Form validation chain by passing TRUE as the second parameter when adding validators to a form, e.g. $element->addValidator('alnum', true). TRUE means the form validation will immediately return.