Answer the question
In order to leave comments, you need to log in
How to display glyphicon fontawesome instead of glyphicon icons in yii2 gridview?
How to display fontawesome instead of glyphicon icons in gridview yii2 that are displayed by default
?
Because I want fontawesome! :)
Answer the question
In order to leave comments, you need to log in
There are several options here:
1. Create your own ActionColumn class and inherit it from the base ActionColumn . In this class, override the desired implementation. As Dmitry Derepko
advises
2. Replacement in one place. If you need to replace only in one place, it makes sense to use Dmitry
's solution
3. Combine all this using a DI container. I always recommend using such a global data substitution. It's more flexible. To do this, we create a Bootstrap class with the implementation of the \yii\base\BootstrapInterface interface . We connect it to the application startup (bootstrap in config.php) and replace everything we need:
$actionColumnSetting = [
'buttons' => [
'view' => function($name, $model, $key){
return Html::a('<i class="fas fa-eye" aria-hidden="true"></i>', ['update']);
},
'update' => function($name, $model, $key){
return Html::a('<i class="fas fa-pencil-alt" aria-hidden="true"></i>', ['update']);
},
'delete' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['delete']);
}
],
];
\Yii::$container->set(ActionColumn::class, $actionColumnSetting);
$actionColumnSetting = [
'buttons' => [
'view' => function($name, $model, $key){
return Html::a('<i class="fas fa-eye" aria-hidden="true"></i>', ['edit']);
},
'update' => function($name, $model, $key){
return Html::a('<i class="fas fa-pencil-alt" aria-hidden="true"></i>', ['update']);
},
'delete' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['delete']);
},
'archive' => function($name, $model, $key){
return Html::a('<i class="fas fa-trash" aria-hidden="true"></i>', ['archive']);
}
],
];
\Yii::$container->set(ActionColumn::class, $actionColumnSetting);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question