是这样的,网页的layout左边有一个列表,内容是动态的,想通过action给layout中的找个组件赋值,但是下面的方法貌似组件接不到值:
action : $this->render(‘view’,array(‘items’=>$items));
layout : $this->widget(‘application.components.List’,array(‘items’,$items));
该怎么做才能传递过去呀?是我传错了还是不能这样传?
是这样的,网页的layout左边有一个列表,内容是动态的,想通过action给layout中的找个组件赋值,但是下面的方法貌似组件接不到值:
action : $this->render(‘view’,array(‘items’=>$items));
layout : $this->widget(‘application.components.List’,array(‘items’,$items));
该怎么做才能传递过去呀?是我传错了还是不能这样传?
Quote
这个修改成这样试试看?
layout : $this->widget('application.components.List',array('items'=>$items))
layout : $this->widget('application.components.List',array('items'=>$items))
谢谢啦,这个帖子是手打的,写错了,但是代码里写的是正确的写法。这样是接收不到值的。
你有调试值是在哪里丢失的吗?
例如:action中,view中,widget中的几个方法。
layout是不能这样传值的。在layout里只有一个$content局部变量。你可以定义一个controller的属性,然后在layout里访问这个属性的值(这样做是合理的,因为layout代表的公共部分,所以需要访问公共值)。
谢谢,辛苦了。
用renderPartial()代替了。