URL in Yii2 GridView
Asked 07 September, 2021
Viewed 2.8K times
  • 49
Votes

I have this code:

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

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?

8 Answer