Where am I going after processing the form?

Hi. I'm having a little confusion with the form example in the guide. It would seem that if the form has an error, the logic in the controller drops through to display the form (and error). Ok.  It also seems if there are no errors, that (according to the comments) control is returned once again to the form.

So my question is, how do I get to the next place…the place one would go via the normal form action? or, in the case of a typical php page where the page processes its own form, the place one would go via a header command after processing the form?  The example seems to keep me on the form page forever.

This is the example on the guide you are reffering to?


public function actionLogin()


    $form=new LoginForm;



        // collects user input data


        // validates user input and redirect to previous page if validated




    // displays the login form



As you can see if the form is correctly validated you redirect the user where you want

Well, I assume from the example (yes, same one) that I could put some another redirect in place of the one that’s there.

But the one that's there, and the comment for it, say that if the form validates, the user will be returned to the previous page.  That's where I get lost. Is there something about the flow of Yii's implementation of MVC that would have me wanting to return the user to the page they just left if there are no errors?

Well, let' say you have a rule that says you can't do something if you aren't a logged in user.

If you try to do it there are 2 possibilities, error page or, if loginUrl is set, you go to the the login page where you can login and (that's what we are talking about here) be returned to the page you tried to open but weren't authorized (now you are)

Tha't the whole point of that


but you can have what you want

i have


on the create form of a guestbook for example



In the form of a loginPortlet i show on every page (that a case of staying in the same page instead of the previous one)

Ah, ok. Perfect explanation, thank you!!

I am assuming that code below send to the refferer page. 

If my assumption above is correct, why I am send to the home page after successful validation? My code is as below: