URL in Yii2 GridView

后端 未结 8 2020
后悔当初
后悔当初 2020-12-15 15:09

I have this code:

 $dataProvider,
  \'filterModel\' => $searchModel,
  \'columns\' => [
    [\         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 15:36

    I think I got the solution:

    The code:

    'value'=>function ($data) {
            return Html::url('site/index');
        },
    

    Should be a bit modified. Let say your field name in array 'country', then code should be like this:

    'value'=>function ($data) {
            return Html::a($data['country'], ['site/index']);
        },
    

    So instead of Html::url I used Html::a and added value of the hyperlink as $data['country']. Hope this helps.

提交回复
热议问题