如何在 yii2 上隐藏详细视图标签 [英] How to hide detail view labels on yii2

查看:35
本文介绍了如何在 yii2 上隐藏详细视图标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏详细视图的标签

I want to hide labels for the detail view

<?= DetailView::widget([
        'model' => $model,
        //To hide labels
        'label' => ['hidden' => true],
        'attributes' => [
             'visits'

        ],
    ]) ?>

在上面的代码片段中,有'label' => ['hidden' => true],存在但不是存在的方法.我想知道有没有一种方法可以隐藏标签 与此等效的东西.

On the above snipet of code, there is 'label' => ['hidden' => true], is there but it is not a method which is existing. I want to know is there a method to hide labels Something which is equivalent to that.

推荐答案

如果你想在 GridView 中隐藏标签列,你必须修改它的 在此处输入链接描述模板.例如:

If you want to hide label column in GridView you must modify its enter link description heretemplate. For example:

<?= DetailView::widget([
    'model' => $model,
    'template' => '<tr><td{contentOptions}>{value}</td></tr>',
    'attributes' => [
        // your attributes for displaying
    ],
]) ?>

如果你想在一个单元格中隐藏一个标签,你可以为 label 属性设置一个空字符串:

If you want to hide a label in one cell you can set an empty string to label property:

<?= DetailView::widget([
    'model' => $model,
    'template' => '<tr><td{contentOptions}>{value}</td></tr>',
    'attributes' => [
        [
            'attribute' => 'id',
            'label' => ''
        ]
        // your attributes for displaying
    ],
]) ?>

这篇关于如何在 yii2 上隐藏详细视图标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆