How do you allow a user to cancel a form submission that has errors and fails validation? Some solutions that were suggested in an earlier post:
1. Override suppressValidation. However, since it's final and can't be overriden, I suspect nobody actually tried this. In any case, it only affects the validation not the workflow. There's still no way to capture the user's action and bail out of the form.
2. Separate form for the cancel button using a GET and a different ACTION. This works, but precludes the use of a generic button bar because the cancel ACTION is hardcoded.
3. Use Javascript to achieve the same effect as #2. Work great as long as the browser has Javascript and it's turned on, neither of which you have any control over.
All of the above soutions are pretty hacky, IMHO. The root issue is that the idea of cancelling a form submission isn't part of the workflow. Granted, HTML is brain-dead that way. Traditional forms have submit and reset, but the only way to bail is to have alternate links. My own hack is to derive from AbstractWizardFormController instead where the cancel action is explicitly trapped for.
Anyone have a clean solution to the problem? I may eventually create an alternate SimpleFormController that traps for cancel, but doesn't bring in all the rest of the Wizard machinery.


Reply With Quote