I have this in one of my models:
public function getDispname() {
return $this->step . '<br>' . $this->pm->dispname;
}
In the View (_pdf.php) I'm calling it inside of a Gridview. When I'm generating a pdf about this in the controller:
$pdf = \Yii::$app->pdf;
$pdf->content = $this->render('_pdf', [
'model' => $model,
]);
$pdf->render();
I'm getting this result:
7. - sometext<br>sometext
Obviously I would like to have an actual line break there instead of a <br>
tag:
7. - sometext
sometext
Can you please tell me how can I make mpdf to render <br>
tags as line breaks?
The text for columns in GridView are automatically encoded.
So to render html you need to format this column as raw text.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
...
// a column with html inside as raw text
[
'attribute' => 'content',
'format' => 'raw', // this will enable html output
],
...
],
]); ?>