I have 1 controller : C
2 functions of that controller : A and B
1 argument of the controller © : arg.
I would like to pass a value from a function to another in the same controller.
My problem is :
I set ‘arg’ in the A function.
But at the end of the function A, I render the A view.
So when I call the function B, from the view of the A view, it founds a ‘arg’ empty…
Like if the controller was built at each call to a function, and destroy when the view is render.
So I don’t know how to pass the value of ‘arg’ from A to B…
I don’t know where to save the value ‘arg’ to call it later.
I would like to let it in the same object, I’m feeling this cleaner to do it like that…
Any ideas ?
mdomba
(Maurizio Domba Cerin)
June 8, 2010, 8:00am
2
When you display a view… a server/client request/response is finished, so any call from that view is a new request/response and at that time the controller/model is again created and you have to assign again the values you need…
you can use the setState() - http://www.yiiframework.com/doc/api/CWebUser#setState-detail
or you can pass that value as a parameter to the request POST or GET
undaverse
(Undaverse)
June 8, 2010, 12:35pm
3
mdomba:
When you display a view… a server/client request/response is finished, so any call from that view is a new request/response and at that time the controller/model is again created and you have to assign again the values you need…
you can use the setState() - http://www.yiiframework.com/doc/api/CWebUser#setState-detail
or you can pass that value as a parameter to the request POST or GET
That was what I thinking…thx
I’ve tried to pass the parameter by POST but it definitely tell me the same thing each time : undifined index ‘arg’
I obviously test my parameter in my B function with isset, but it seems to don’t want to work…
In fact everything is fine until I render the view where a don’t recognize the parameter anymore, in the controller everything is fine…