I’m new to Yii and I have a controller action that is invoked after a form is posted, depending on user input a db query is made and the next page is rendered with info from the database. What is the recommended way to move to the next view ?
I think I would prefer to use redirect but I’m not sure what is the “recommended” way. I could do after input is validated:
$this->actionNextAction(…); //problem is the URL is not changing and I want the URL to change aswell
$this->redirect(array("site/nextAction", 'sid'=>$_POST['IndexForm']['someid'])); //URL is changed I'm still unsure i'm doing something stupid.
It seems to me like using redirect() is fine. If you look at the gii default controller code that gets generated, redirect() is used after saving models in actionUpdate(), etc. so you are probably already doing it this way in some places if you used gii to get your controllers started.
Thanks I’m happy with this solution I suppose after a while working with Yii things will get clear and hopefully I’ll learn quickly.
Next I need to figure out how to and where to store class objects I was thinking $_SESSION but I’ll google a bit still once I have the spare time again to dev with Yii. Basically I want to avoid having to assign things in hidden inputs on forms when I have no intention of allowing the user to change the value. Obviously I could just store the data I need but since the data I need is the whole class object I might as well store the object and unset it from the session when I no longer need it.