Yii2 GridView 中的 URL

2021-12-24 00:00:00 php yii2 yii gridview

我有这个代码:

<?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'],
  ],
]); ?>

在网格视图中生成带有 URL 地址的文本.

In grid view text is being generated with URL address.

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

URL 工作正常,但如何为链接设置文本?

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

推荐答案

Use 'format' =>'raw' 而不是 'format' =>'url'.

相关文章