2017-04-13 15:22:59 5058次浏览 3条回答 2 悬赏 10 金钱

view层显示的代码

 <?= DetailView::widget([
                'model' => $model,
                'attributes' => [
                    'news_id',
                    [
                        'label' => '栏目名',
                        'value' => $model->findCateName()->catname
                    ],
                    'title',
                    'description',
                    'content:ntext',
                    'inputtime:datetime',
                    [
                        'label' => '状态',
                        'value' => $model->status == 1 ? '启用' : '禁用'
                    ]
                ],
            ]) ?>

QQ截图20170413152153.png
上图为显示的内容,我不想让它转义,怎么处理??

最佳答案

  • 回答于 2017-04-13 17:11 举报

    你存的内容不对吧?看看数据库中存的内容,是不是转成其他格式了,使用ntext是可以正常显示html的。

  • 回答于 2017-04-25 12:50 举报
    [
        'label' => 'test',
        'value' => \yii\bootstrap\Html::button('test'),
        'format' => 'raw', // 转义
    ],
    
您需要登录后才可以回答。登录 | 立即注册
王文凡
经理

王文凡 ChengDu

注册时间:2016-04-11
最后登录:2018-07-26
在线时长:20小时44分
  • 粉丝3
  • 金钱1065
  • 威望10
  • 积分1365

热门问题