我已经创建了一个 Yii2 Gridview 小部件,我想仅在行上显示“V”标记等于我从控制器传递的另一个渲染变量:
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'header' => 'Default',
'content' => function ($model) {
if ($model->id == $selected) {
return Html::tag('i','',['class' => 'fa fa-check']);
}
return '';
}
],
从控制器传递:
return $this->render('index', [
'selected' => $selected,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
但我收到一个错误:
未定义变量:已选择
我错过了什么?