Skip to content

Menu widget item icon doesn't support img tag #93

@Shifrin

Description

@Shifrin

What steps will reproduce the problem?

I'm trying to create a menu using Yiisoft\Yii\Widgets\Menu widget, but my goal is to use svg image as icon which requires a img tag instead of i tag. Which seems not possible because of i tag explicitly used in the Yiisoft\Yii\Widgets\Helper\Normalizer::menu().

I tried to create the img tag in a following way, but it didn't work as expected.

[
    'label'     => 'Dashboard',
    'link'      => administration_url('dashboard/index'),
    'iconAttributes' => [
        'tagName' => 'img',
        'src' => 'icon-url',
        'alt' => 'Dahsbaord'
    ]
]

Please note that the widgets I'm trying to use in a Yii2 application.

What is the expected result?

<img src="icon-url" alt="Dashbaord"/>

What do you get instead?

<i src="icon-url" alt="Dashbaord"></i>

Additional info

Q A
Version ^2.1
PHP version 8.3
Operating system php:8.3-fpm-alpine

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions