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 ;)
missing the pjax header tags
nice tip. thanks for sharing. just one thing to add if using pjax:
'data' => [ ... 'pjax' => 0, ],
otherwise page will refresh after each delete as those are the default values initialized by ActionColumn::init():
'title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0',
This is not working with Bootstrap v. 4, delete confirm alert is not shown. How can we fix it?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.