In gridview add 'format' => 'raw'
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
[
'attribute' => 'book',
'label' => 'Books',
'format' => 'raw', //this line disables html encoding
'value' => function ($data) {
return Html::img('@web/books/book_id.jpg', [
'alt' => 'Harry Potter', 'class' => 'my_class'
]);
}
],
'user_id',
],
]);
In form field add ['encode' => false]
$form->field($model, 'bookList')->radioList([
1 => Html::img('@web/books/book_1.jpg'),
2 => Html::img('@web/books/book_2.jpg')
], ['encode' => false])->label();
Comments
Post a Comment