Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73875

Embed "i" tag into "a" tag in CakePHP

$
0
0

With CakePHP 3.7.9 I want to place an i tag (to shown an icon) inside an a tag. Here my code:

private function resetButton(array $options = []):string
{
    $params = $this->_View->getRequest()->getQueryParams();
    if (!empty($params)) {
        foreach ($params as $field => $value) {
            if (substr($field, 0, 7) === 'Filter-') {
                unset($params[$field]);
            }
        }
    }
    $options = Hash::merge($this->getConfig('resetButtonOptions'), $options);
    $url = Hash::merge($this->request->params, [
        'resetFilter' => true
    ]);

    return $this->Html->link($this->Html->tag('i', '', ['class' => 'fa fa-eraser']), Router::reverse($url), $options);
}

this renders to:

<a href="/products?_csrfToken=blablabla;resetFilter=1" class="btn btn-default" pass="1">&lt;i class="fa fa-eraser"&gt;&lt;/i&gt;</a>

that means it's translated literally, instead I want to generate an i tag. If I open the developer tools of my broswer, delete the inner html of the a tag and paste the expected content (<i class="fa fa-eraser"></i>) it renders correctly.

Is my PHP sentence above wrong?


Viewing all articles
Browse latest Browse all 73875

Trending Articles