Yii Framework Forum: Make link between 2 functions of a controller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Make link between 2 functions of a controller Rate Topic: -----

#1 User is offline   undaverse 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 19-April 10

Posted 08 June 2010 - 02:55 AM

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 ?
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,338
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 June 2010 - 03:00 AM

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.yiiframew...setState-detail

or you can pass that value as a parameter to the request POST or GET
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   undaverse 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 19-April 10

Posted 08 June 2010 - 07:35 AM

View Postmdomba, on 08 June 2010 - 03:00 AM, said:

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.yiiframew...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...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users