I'm using the KnpMenuBundle for Symfony2 and I couldn't find a way to add a css class to the from the Menu generated links.
What I tried to set the class to the child attribute, but that will not be given to the link but to possible children menus (submenus).
$menu->addChild('agb', array('uri' => '#'))
->setAttribute('divider_append', true)
->setChildenAttribute('class', 'childClass');
This will result into the following HTML
<li>
<a href="#"> agb </a>
<ul class="childClass">
....
</ul>
</li>
But I need it like this:
<li>
<a href="#" class="childClass"> agb </a>
<ul>
....
</ul>
</li>
How can I do this?
$menu->addChild('agb', array('uri' => '#'))
->setAttribute('divider_append', true)
->setLinkAttribute('class', 'childClass');
easy as that :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With