A
A
agent11562017-01-31 14:30:55
Yii
agent1156, 2017-01-31 14:30:55

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

2 answer(s)
D
Dmitry, 2017-01-31
@slo_nik

Good afternoon.
To do this, you need to use roles (rbac)
Start with this article .

M
Maxim Timofeev, 2017-02-01
@webinar

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 question

Ask a Question

731 491 924 answers to any question