Answer the question
In order to leave comments, you need to log in
How to do validation in GridView?
Such code in index
How to check if('username' == 'admin'){ 'template' => '{delete} }
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'username',
//'auth_key',
//'password_hash',
// 'pas//sword_reset_token',
// 'email:email',
// 'status',
// 'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn', 'template' => '{delete}'],
],
]); ?>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
To do this, you need to use roles (rbac)
Start with this article .
everything is in the docs:
www.yiiframework.com/doc-2.0/guide-output-data-wid...
[
'class' => ActionColumn::className(),
'visibleButtons' => [
'delete' => (Yii::$app->user->identity->username == 'admin')?true:false,
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question