diff --git a/widgets/Nav.php b/widgets/Nav.php old mode 100644 new mode 100755 index 7f96389..4f9d1a8 --- a/widgets/Nav.php +++ b/widgets/Nav.php @@ -72,6 +72,11 @@ class Nav extends \yii\bootstrap\Nav { */ const ITEM_DIVIDER = 'divider'; + /** + * Tags + */ + const TAG_LINK = 'a'; + /** * @var array list of items in the nav widget. Each array element represents a single * menu item which can be either a string or an array with the following structure: @@ -135,7 +140,7 @@ public function renderItem($item) } $items = ArrayHelper::getValue($item, 'items'); - + if ($items === null) { return parent::renderItem($item); @@ -145,7 +150,7 @@ public function renderItem($item) { throw new InvalidConfigException("The 'label' option is required."); } - + $dropdownType = ArrayHelper::getValue($item, 'dropdownType', self::TYPE_DEFAULT); $options = ArrayHelper::getValue($item, 'options', []); @@ -218,14 +223,26 @@ private function _getLinkTag($item) Html::addCssClass($linkOptions, 'dropdown-toggle'); + $tag = ArrayHelper::getValue($item, 'tag', 'a'); + $url = ArrayHelper::getValue($item, 'url', false); if (!$url) { - return Html::a($label, 'javascript:;', $linkOptions); + if (self::TAG_LINK == $tag) + { + $linkOptions['href'] = 'javascript:;'; + } + + return Html::tag($tag, $label, $linkOptions); + } + + if (self::TAG_LINK == $tag) + { + $linkOptions['href'] = Url::toRoute(ArrayHelper::getValue($item, 'url', '#')); } - return Html::a($label, Url::toRoute(ArrayHelper::getValue($item, 'url', '#')), $linkOptions); + return Html::tag($tag, $label, $linkOptions); } /**