Sarvar Nishonboyev Sarvar Nishonboyev - 1 year ago 322
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'],
'format' => 'url',
'value'=>function ($data) {
return Html::url('site/index');
['class' => 'yii\grid\ActionColumn'],
]); ?>

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


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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download