The yii\helpers\Html::a()'s description for $options
says (emphasis mine):
The tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using encode(). (…)
How can I avoid that and force Yii 2 to not-encode values of these attributes?
I am generating a rich-text title to use Bootstraps 5’s Tooltip like that:
<?php $tooltip = (is_array($response) && count($response) > 0) ? [
'data-bs-html' => 'true',
'title' => HTML::decode($this->render('/command/_response', [
'response' => $response,
'options' => ['style' => "text-align: left"]
])),
] : []; ?>
It is then put as $options
in a():
<td><?= Html::a($type' . ' (' . $status . ')', [
'/command/view',
'id' => $command->id
], $tooltip) ?></td>
Neither style="text-align: left"
nor view’s internal <div class="rendered-command-response">
gets respected by browser, because it ends up encoded:
<a href="/root/app/web/controller/action?id=1" title="
<div class="rendered-command-response">
<div style="text-align: left">
L1 = <strong>11.11</strong> mm
L2 = <strong>22.22</strong> mm
L3 = <strong>33.33</strong> mm
P1 = <strong>32.1</strong> mm
P2 = <strong>22.37</strong> mm
P3 = <strong>12.34</strong> mm
</div>
</div>" data-bs-html="true">
How can I work-around this problem and get correct HTML content of Bootstrap 5’s tooltip?