Commit 85fd823e by Dmitry Chernikov

Added ability to `yii\widgets\Menu` to encode each item's label separately (creocoder, umneeq)

parent 13465be8
......@@ -53,6 +53,8 @@ class Menu extends Widget
*
* - label: string, optional, specifies the menu item label. When [[encodeLabels]] is true, the label
* will be HTML-encoded. If the label is not specified, an empty string will be used.
* - encode: boolean, optional, whether this item`s label should be HTML-encoded. This param will override
* global [[encodeLabels]] param.
* - url: string or array, optional, specifies the URL of the menu item. It will be processed by [[Url::to]].
* When this is set, the actual menu item content will be generated using [[linkTemplate]];
* otherwise, [[labelTemplate]] will be used.
......@@ -255,7 +257,8 @@ class Menu extends Widget
if (!isset($item['label'])) {
$item['label'] = '';
}
$items[$i]['label'] = $this->encodeLabels ? Html::encode($item['label']) : $item['label'];
$encodeLabel = $this->encodeLabels || isset($item['encode']) && $item['encode'] === true;
$items[$i]['label'] = $encodeLabel ? Html::encode($item['label']) : $item['label'];
$hasActiveChild = false;
if (isset($item['items'])) {
$items[$i]['items'] = $this->normalizeItems($item['items'], $hasActiveChild);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment