pass object from one action to another

How can we pass object from one action to another of same Controller or across Controllers ?

There are so many fields I can not pass through redirect using GET variables.

Hey,

why do you want to do that? Can you show us a example why u would need that?

You can use the session (or $user->setState) and save serialize(object) or serialize($model->getAttributes()) …

actually, I am making a 3 step registration where first step is setting some properties of a class and then second screen sets some other properties of same class and finally after 3rd step, I am persisting completely set object to DB. I have used objects which have local scope inside a method. That’s why I needed to do this.

I did similar to what you said and I haev stored the object to session.


Yii::app()->session['_model'] = $model;

And then while retrieving, I am reading the object as below…


$obj=Yii::app()->session['_model'];

it’s usually a bad idea to store whole objects into the session, the session will get pretty big depending on the objects you store.

What I would do instead is to use some javascript to switch between the different forms and handover the object in json.