代码如下:
<?= DetailView::widget([
'model' => $model,
'template'=>'<tr><th style="width:120px;">{label}</th><td>{value}</td></tr>',
//template 是控制每一行的样式模板 可以增加列
'options'=>['class'=>'table table-striped table-bordered detail-view'],
//options 设置整个table的类名
'attributes' => [
'id',
'title',
// 'content:ntext',
'tags:ntext',
// 'status',
[
'label'=>'状态', //标签
'attribute'=>'status', //传过来的属性值
'value'=>$model->status0->name, //对值进行操作
],
// 'create_time:datetime',
[
'attribute'=>'create_time',
'value'=>date('Y-m-d H:i:s',$model->create_time),
],
// 'update_time:datetime',
[
'attribute'=>'update_time',
'value'=>date('Y-m-d H:i:s',$model->update_time),
],
// 'author_id',
[
'attribute'=>'author_id',
'label'=>'作者',
'value'=>$model->author->nickname,
]
],
]) ?>