Geoff
Geoff

Reputation: 6629

error on kartik dynagrid

Am implementing the kartik dynagrid but get an error of only variables should be passed.

This is the code that i have tried:

The columns

      <?php
       $columns = [
            'id',
            'username',
            'first_name',
            'other_names',
            'email',
            [
                'class' => ActionColumn::className(),
                'header' => 'Roles',
                'template' => '{assign-roles}',
                'buttons' => [
                    'assign-roles' => function ($url, $model, $key) {

                        return Html::a("Assign Role", $url);
                    }
                ]
            ],
            [
                'class' => ActionColumn::className(),
                'header' => 'Action',
                'buttons'=>[
                    'delete'=>function($url, $model, $key){
                        return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
                            'title' => Yii::t('yii', 'Delete'),
                            'data-confirm' => Yii::t('yii', 'Are you sure to delete this item ?'.
                            'We recommend deactivating the user to avoid inconcistencies with the data this user handled'),
                            'data-method' => 'post',
                        ]);

                    }
                ]
            ]
        ];

This is the grid

            echo DynaGrid::widget([
            'columns' => $columns,
            'showPersonalize' => true,
            'options' => ['id' => 'dynagrid-users'],
            'gridOptions' => [
                'dataProvider' => $dataProvider,
                'pager' => [
                    'firstPageLabel' => 'First',
                    'lastPageLabel' => 'Last',
                    'maxButtonCount' => 10,
                ],
                'panel' => [
                    'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-book"></i> All Users</h3>',
                    'before' =>
                        '<i>* All Users in the database</i><br>',
                    //'after'=>Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['index'], ['class' => 'btn btn-info']),
                    'footer' => true
                ],
                'toolbar' => [
                    ['content' => '{dynagridFilter}{dynagridSort}{dynagrid}'],
                    '{export}',
                    '{toggleData}'
                ],
                'pjax' => true,
                'bordered' => true,
                'striped' => true,
                'condensed' => true,
                'responsive' => true,
                'responsiveWrap' => false,
             ]
        ]);

?>

I always receive an error of Only variables should be passed by reference.

Upvotes: 1

Views: 250

Answers (1)

devOp
devOp

Reputation: 3170

You are working with an older version of dynagrid. Update the dynagrid, this error is already fixed. Here is the Github Issue.

Upvotes: 1

Related Questions