Arun VM
Arun VM

Reputation: 447

How to hide detail view labels on yii2

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.

Upvotes: 0

Views: 1202

Answers (1)

Maksym Fedorov
Maksym Fedorov

Reputation: 6456

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

Upvotes: 2

Related Questions