答案 0 :(得分:13)
在链接列配置中添加:
'format' => 'html',
或者如果你想要一些额外的标记
'format' => 'raw',
如果raw
记得编码来自外部用户的值,因为它不是自动完成的。
答案 1 :(得分:1)
在Yii中执行此操作的更好方法。
+----+-----------------------------------------------------+---------+
| id | url | content |
+----+-----------------------------------------------------+---------+
| 1 | https://www.npmjs.com/package/pg | |
+----+-----------------------------------------------------+---------+
| 2 | https://github.com/thomasdondorf/puppeteer-cluster/ | |
+----+-----------------------------------------------------+---------+
Yii文档:https://www.yiiframework.com/doc/api/2.0/yii-helpers-basehtml#a()-detail
发布晚了一点,但希望对以后有所帮助。
答案 2 :(得分:1)
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'email:email',
'timestamp:date',
[
'attribute'=>'Resume',
'format' => 'raw',
'class' => 'yii\grid\DataColumn', // can be omitted, as it is the default
'value' => function ($data) {
$url = "www.sample.com/contactform/resumes".$data->resumepath;
return Html::a('<i class="glyphicon glyphicon-download-alt"></i>', $url);
},
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>