kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
557 stars 302 forks source link

Issue with Closure in contentOptions for ExpandRowColumn starting from v3.2.9 #991

Closed VladimirBarabash closed 2 years ago

VladimirBarabash commented 3 years ago

Prerequisites

Steps to reproduce the issue

  1. Render kartik\grid\GridView with kartik\grid\ExpandRowColumn with Closure in contentOptions:
    echo kartik\grid\GridView::widget([
    ...
    'columns' => [
        [
            'class' => 'kartik\grid\ExpandRowColumn',
            'value' => function ($model, $key, $index, $column) {
                return GridView::ROW_COLLAPSED;
            },
            'detailUrl' => Url::to(['/update']),
            'contentOptions' => function ($model, $key, $index, $widget) {
                return $model->isHighlighted ? ['class' => 'highlighted'] : [];
            },
        ],
        ...
    ],
    ]);
  2. Open page in browser

Expected behavior and actual behavior

When I follow those steps, I see "Error. Cannot use object of type Closure as array": error

I was expecting no error message, Closure in contentOptions working for ExpandRowColumn like in version 3.2.8

Environment

Browsers

Operating System

Libraries

Isolating the problem

There is no bug in version 3.2.8. There is bug in versions 3.2.9-3.3.5, dev-master