Sarvar Nishonboyev Sarvar Nishonboyev - 4 months ago 67
PHP Question

URL in yii2 gridview

In yii2 gridview, I have this code:

<?php echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'label'=>'bla',
'format' => 'url',
'value'=>function ($data) {
return Html::url('site/index');
},
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>


In grid view, text is being generated with url address.

/academia-new/advanced/admin/site/index

Url is working fine, but how can I set a text for link?

Answer

Use 'format' => 'raw' instead of 'format' => 'url'.

Comments