yii2 DetailView 相关问题
1、内容实体转换:
只需要把'store_content:ntext'改成'store_content:raw' 即可完成转换
PHP Code复制内容到剪贴板
- <?= DetailView::widget([
- 'model' => $model,
- 'template' => '<tr><td width="80">{label}</td><td>{value}</td></tr>',
- 'attributes' => [
- 'id',
- 'category_id',
- 'title',
- 'content:raw',
- 'titlepic',
- [ // the owner name of the model
- 'attribute' => 'created_at',
- 'value' => date("Y-m-d H:i:s",$model->created_at),
- ],
- ],
- ]) ?>
2、DetailView可以自由定义样式
PHP Code复制内容到剪贴板
- <?= DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'uid',
- ['label'=>'gender','value'=>$model->getGenderText()],
- ],
- 'template' => '<tr><th>{label}</th><td>{value}</td></tr>',
- 'options' => ['class' => 'table table-striped table-bordered detail-view'],
- ]) ?>