How to hide detail view labels on yii2

人盡茶涼 提交于 2019-12-11 15:35:13

问题


I want to hide labels for the detail view

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

        ],
    ]) ?>

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.


回答1:


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
    ],
]) ?>

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
    ],
]) ?>


来源:https://stackoverflow.com/questions/53959698/how-to-hide-detail-view-labels-on-yii2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!