I can simply add
disabled class to any Bootstrap 5 button:
<?= Html::a(Yii::t('backend-views', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger' . (($totalSum > 0) ? ' disabled' : ''),
'data' => [
'confirm' => Yii::t('views', 'Are you sure you want to delete this user?'),
'method' => 'post',
And I can be sure that both button’s look will change (into dimmed one) and this button won’t trigger click anymore.
How can I achieve the same with ActionColumn’s buttons?
I know how to hide some ActionColumn’s button – using
visibleButtons property seems most convenient. There are number of topics about this (here, here and here). But how to disable it?
Because drawing buttons is drawing just links with correct CSS you can easily customize it by writing your own callbacks to $buttons property. Extend the example from API:
That’s the whole point. I don’t want to recreate (in my custom class) the whole rendering / drawing process that is nicely done in ActionColumn class. I just want to apply “disabled” (or any other) class to selected button
So, the question is more like – if construction of ActionCloumn allows changing options / class / attributes of separate button? Or all buttons at all only?
Because in second case, using callback and designing own button drawing method seems to be the only way.