I want to insert a span tag into an item in Nav widget trying to do it like this

['label' => 'Корзина ' . Html::tag('span',$itemsInCart ? " ($itemsInCart)": '',['id'=>'itemsCounter']), 'url' => ['/cart/list'],], 

the menu accordingly gives me here a cart (11) how do I display the tech in the menu of the Nav widget

  • and what you want to get something? you now have (11) in span with id = itemsCounter, everything seems to have been ordered - kroder
  • You like the menu button of the type Basket <span id = "itemsCounter"> (11) </ span> and the text is the same, but I have already solved the question. - Sergalas
  • And, you would have clarified right away, otherwise the Recycle Bin (11) looks quite normal) With 'encodeLabels' => false yes, there is such a moment. - kroder
  • @kroder make out the answer I confirm. Thank you - Sergalas

1 answer 1

So the problem is that by default in Yii label widgets pass through the HTML code and any html tags will be printed as text. Therefore, if in the text of labels you need an html layout, then you need to set the property 'encodeLabels' => false near the widget.