I'm trying to make a radio list, with html content inside, where i want to have a title, and an image, from this code:
$items=array();
foreach ($templates['user'] as $template) {
$item = $template['name'];
$item .= Html::encode("<div>".Html::img($template['preview_image'])."</div>");
$items[] = $item;
}
And then to display it
echo Html::radioList('templates', null, $items, ['separator'=>"<hr />",'encode'=>'html']);
But it doesn't work. I get the html code in the view. Any ideas?
Thanks in advance!
You are encoding your html on the line:
$item .= Html::encode("<div>".Html::img($template['preview_image'])."</div>");
Try removing Html::encode()
.
Edit:
Also, try changing the option encode
to false
:
echo Html::radioList('templates', null, $items, ['separator'=>"<hr />",'encode'=>false]);