<?=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’
Bizley
(Bizley)
2
Try
Html::a('a',['asdf'],['data-url'=>Url::to(['index']),'class'=>'btn btn-xs btn-success'])
Pasman
(Pasman P)
4
Which version of yii you use ?
btw there is syntax error:
syntax error, unexpected ']'
adzayko
(Storytellercontact)
5
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
rahif
(Rahif)
6
<?=DetailView::widget([
...
)] <-- here change the order
?>
abhidhi000
(abhidhi000)
7
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.