Passing Variable From One View File To Other

How can I pass variable from one view to other view file? Suppose I have a $var in _list.php and I want pass this variable to _graph.php such that I can write echo $var in _graph.php file. Is their any way to solve this problem?

Use post or get with hiddenfields!! u can also use session!!

write codes in controller,then u can pass at the time of render!!

if the second view is loading by a simple link, then u can pass through link!!

if its ajax, u can use renderpartial!!

According to your usage, there are lots of methods!!

If you’re talking about rendering one view inside another, take a look at renderPartial

You can pass any data via second arg.

I doing something like this in my _list.php


$this->widget('bootstrap.widgets.TbTabs', array(



array('label'=>'Dash2', 'id'=>'dash2', 'content'=> $this->renderPartial('_graph', true, true)),

Now I want to pass $someID to _graph. I tried something like this

'content'=> $this->renderPartial('_graph', array('someID'=>$someID), true))

But it doesn’t work. When I tried echo $someID in _graph.php, it gives error $someID doen’t exist.

use this:

'content'=> $this->renderPartial('_graph', array('someID'=>$someID)));

That arg which you set it true, returned the script of that file, but in this case it render that file in your current view file.

ok my mistake. Following code

'content'=> $this->renderPartial('_graph', array('someID'=>$someID), true))

is working. I made some other mistake. Thanks ORey.

try this line below the block with some static id for trouble shoot!!.

$this->renderPartial('_graph', array('someID'=>$someID), false,true)