Hi
I’m trying to add a particular class to each row in my grid depending on the outcome of an if statement.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'rowOptions' => function ($model, $index, $widget, $grid){
if($model->option->correct_answer == 1){
return ['class' => 'success'];
} else {
return ['class' => 'danger'];
}
},
But I always get array_merge(): Argument #2 is not an array in my stack on GridView.php
foreach ($this->columns as $i => $column) {
if (is_string($column)) {
$column = $this->createDataColumn($column);
} else {
$column = Yii::createObject(array_merge([
'class' => $this->dataColumnClass ? : DataColumn::className(),
'grid' => $this,
], $column)); // here
I looked at Cebe’s answer here and I thought my attempt was ok here https://github.com/yiisoft/yii2/issues/2588
What have I got wrong here