This might sound like an odd scenario, but I’ve got two forms on one page. One is just posting back to itself. I made the second post to another action to keep the code cleaner. Maybe not the right choice…
The problem I’m having now is that if that second form doesn’t validate, I redirect back to the page with the form but I don’t know how to keep my form fields filled in with the original information the user entered. Is there a way to do that and keep posting to two separate actions, or do I need to just bite the bullet and have both forms post back to the same action and deal with the messy logic?
I would submit both forms to the same action. There really shouldn’t be anything too messy about it. In each form include a hidden field to signify which form is being submitted.
Application_Form_Login:
Application_Form_Register:
Controller:
View:
With this type of a setup, if either of your forms fail validation,
isValid()will preserve any data that has been entered and you still redirect on a successful validation of one or both of the forms.