How to change GridView delete confirmation message for specific controllers only?

You are viewing revision #1 of this wiki article.
This is the latest version of this article.

Hello,
If you want to give extra attention for some specific delete actions and you don't want to override whole yii.confirm JS method here is what you can do:
(I've only put the ActionColumn part of the GridView here to just give you the idea)

[
    'class' => 'yii\grid\ActionColumn',
    'template' => '{update} {delete}',
    'buttons' => [
        'delete' => function($url, $model){
            return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['delete', 'id' => $model->id], [
                'class' => '',
                'data' => [
                    'confirm' => 'Are you absolutely sure ? You will lose all the information about this user with this action.',
                    'method' => 'post',
                ],
            ]);
        }
    ]
],

Hope this will help you on your next project ;)

3 0
4 followers
Viewed: 46 194 times
Version: Unknown (update)
Category: Tips
Written by: AlaFalaki
Last updated by: AlaFalaki
Created on: Feb 28, 2016
Last updated: 8 years ago
Update Article

Revisions

View all history

Related Articles