Answer the question
In order to leave comments, you need to log in
How to add button in gridview filter?
There is a table output code in Yii2.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'layout'=>"{items}",
'columns' => [
[
'label'=>'Название',
'attribute'=>'name',
'format' => 'raw',
'value'=>function ($data) {
$typeURLs = [
1 => 'open',
2 => 'close',
3 => 'channel',
4 => 'bot',
];
$viewLink = (isset($typeURLs[$data->type]) && isset($data->slug)) ? '/'.$typeURLs[$data->type].'/'.$data->slug : '#';
return Html::a($data->name,'http://t-c.ru'.$viewLink);
},
],
// 'description:ntext',
],
]); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question