我在控制器中填充了 $model1、$model2 和 OwnerID,它在我的 zii.widgets.grid.CGridView 中呈现数据当我想将 $model2 发送到视图时出现问题,如下所示:
$this->render('listView', array('model1'=>$model, 'model2' => $model2, 'OwnerID' => 14));
在我看来,我有:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'listKeys',
'dataProvider'=>$model1->search($OwnerID),
'summaryText'=>'Showing {start} to {end} of {count} keys.',
'columns'=>array(
array('value'=>'$data["id"]', 'header'=>'Key ID'),
array(
'type'=>'raw',
'header'=>'Edit',
'value'=>'CHtml::dropDownList("partyList","owner_party_id", $model2)'
),
),
));
我得到“ Undefined variable: model2 ” $model2 中有数据,如果我注释掉网格中的下拉列表并在网格外有下拉列表,如下所示:
<?php echo CHtml::dropDownList("partyList","owner_party_id", $model2) ?>
然后一切正常。如何在 CGridView 中添加 dropDownList?$model1 是文件列表,$model2 是用户列表。