URL in Yii2 GridView

Sarvar Nishonboev picture Sarvar Nishonboev · Apr 10, 2014 · Viewed 56.5k times · Source

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

Ajey picture Ajey · May 24, 2014

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