如何在detailView行中制作URL

Moh*_*ari 1 php detailview yii2 yii2-advanced-app

如何在 yii2 上的行中创建URLDetailView

例如:blow 代码类似于 中的自定义行GridView,但正如您所知,DetailView它是不同的,并且此代码在 中不起作用DetailView

 <?= DetailView::widget([
      'model' => $model,
      'attributes' => [
   [
   'attribute' => 'file',
   'label' => 'File',
   'fomat' => 'Url', // I want something like this
   'value' => Html::a('Dowaload The File', ['files/uloads']),
   ],
])
Run Code Online (Sandbox Code Playgroud)

我还没有在类似的问题中找到我的问题的解决方案。

请帮助我UrlDetailView中创建行。

gmc*_*gmc 5

您可以使用简写 url 格式化程序(不提供太多自定义选项):

'attributes' => [
  'file:url'
]
Run Code Online (Sandbox Code Playgroud)

或者raw您可以自定义所有内容的格式:

'attributes' =>[
  [
    'attribute'=>'file',
    'label'=>'File',
    'format'=>'raw',
    'value'=>Html::a('Download the File', url),
  ],
...
Run Code Online (Sandbox Code Playgroud)