lost html tag in DetailView widget


        'model' => $model,

        'attributes' => [

            'attribute' => 'name',

            'format' => 'html',

            'value' => Html::a('a',['asdf'],['data'=>['url'=>Url::to(['index'])],'class'=>'btn btn-xs btn-success']





output html is lost “‘data’=>[‘url’=>Url::to([‘index’]”

but have ‘class’=>‘btn btn-xs btn-success’


Html::a('a',['asdf'],['data-url'=>Url::to(['index']),'class'=>'btn btn-xs btn-success'])

Thank you for answer!

But the problem remains.

Which version of yii you use ?

btw there is syntax error:

syntax error, unexpected ']'

So basically you want to add a link in you data-url(data attribute)

Html::a('a',['asdf'],['data-url' => Url::to(['index']),'class'=>'btn btn-xs btn-success'])

This should work



    )]  <-- here change the order


I don’t know why so much wrong answer given in this website.

For the Grid view you can use content instead of value.

For detail view you can’t use content so you can use ‘format’ => ‘raw’ , after value.

It’s working.

just set format to ‘raw’ instead of ‘html’.this worked for me.