Yii2: Detail view widget Add Button / HTML

I am trying to add button in yii2 detail view widget. Previously I done with Yii2 grid view widget. I can’t able to do the same in detail view.

My code below,


<?= DetailView::widget([

        'model' => $model,

        'attributes' => [

            'id',

            'Name',

            'Email:email',

            'Phone',

            'server_status',

            [

                'label'=>'Server',

                'value'=>"<button>Server Started</button>",

            ],

        ],

    ]) ?>

Please kindly help to solve this issue.

You need to add format field to your DetailView widget




 [

                'label'=>'Server',

                'format'=>'raw',

                 'value'=>"<button>Server Started</button>",

            ],



1 Like

value could also be:

‘value’=> $model->filename . ’ ==>> ’ . Html::a(‘Download’, [‘document/download’, ‘param’ => Html::encode($model->dealer . ‘/’ . $model->fullName . ‘/’ . $model->filename)]

this gives you more flexibility