Reputation: 71
I need to include some html code inside Html::button in yii2. According to the Class yii\helpers\BaseHtml i can pass html code to $content. Please, correct me if i am wrong. So i wrote:
<?= Html::button{'<div class=\'row\'></div>,[]); ?>
and it works. But what if the code i want to insert is big? How do i include big code with less pain?
Thank you very much.
Upvotes: 0
Views: 872
Reputation: 1663
You could use views and renderPartial
e.g. in your view
<?php
$html = $this->context->renderPartial('sub_view', [
'attribute' => 'test',
]);
echo Html::button($html,[]);
?>
and in your subview your static html or dynamic code
<h1>static html code<h1>
<div>
<?php
echo $attribute
?>
</div>
Upvotes: 1