Form Input and Validation after redirect

I have run into this scenario a few times and wondering if anyone has a good solutions or if I am thinking about it wrong.

I have a controller that creates a form and maybe generate some other stuff.

The view displays the form and maybe some other stuff.

Now with this form I want it to call a different action/url when submitted.

Here is the catch if the form is invalid or operation can not be performed for whatever reason, I want it to go back to the previous controller and display the errors. If I use a redirect I lose all the information.

I know I could use ajax validation but this not always a guarantee until I actually perform the operation.

Flash variable is not good since it doesn’t deal with the form information.

What use cases do you have in mind?

Usually you don’t need to submit a form to a different action. Just perform the validation and other necessary process in the same controller until you get the correct result, and redirect to another action when all get done. You should have already been familiar with it, as it is the case with the “create” and “update” actions that CRUD generator of Gii generates for you.

And, if you do want to submit a form to a different action, you can set "action" of the form to it.$action-detail

In that case, you must create an instance of the model of the form in that controller action to handle the submitted form data. Ajax validation will also be handled with it. A form in a popup may be handled simpler and cleaner with this approach.