Yii Framework Forum: How to pass variable value to a different controller ? - Yii Framework Forum

Jump to content

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

How to pass variable value to a different controller ? Rate Topic: -----

#1 User is offline   munemune 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 07-November 09

Posted 30 December 2009 - 06:32 AM

Hi, How to pass variable value to a different controller ?

I was try to build application that need to interact using 2 or more models.

My first methode (and its working) is to build single controller and many view for different scenario, well it's quite long work.

Now i try my second methode, that is when user do something to one view (that connect to some model) user will redirecting to that model controller thus that specific controller will take over, including view etc.

The problem is i need to pass some variable from controller to another controller, the point is i need to 'hide' some values so that the user wont make a mistake when input a form in another controller/view (what i need is not validator kind)

Thank You
0

#2 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 244
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 31 December 2009 - 02:56 AM

In this case, I set some session vars and then I do a redirection :

$session = Yii::app()->session;
if ($model->validate())
                {
                    $model->save(false);
                    $session['success'] = $model->foobar;
                    $this->redirect(array(bu() . '/controller/action'));
                }

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
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