Answer the question
In order to leave comments, you need to log in
How can I get the cell object in the GridView to use RBAC validation?
Let's have this code:
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns'=>[
['class'=>'yii\grid\SerialColumn'],
[
'label'=>'User',
'attribute'=>'users.userName'
],
'title',
'text',
'date',
'time',
[
'class' => 'yii\grid\ActionColumn',
'header'=>'Actions',
'template'=>'{view} {update} {delete} ',
'buttons'=>[
'view'=>function($url)
{
return Html::a('Открыть',$url);
},
'delete'=>function($url)
{
return Yii::$app->user->can('deletePost') ? Html::a('Удалить',$url) : null ;
}
]
],
]
]);
Yii::$app->user->can('updatePost',['posts'=>$post]) ? Html::a('Update',$url) : null ;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question