Hide menu container tag when items is empty

This commit is contained in:
artur
2014-05-30 02:19:07 +03:00
parent 28949b3ab4
commit d2fcbcc0e0

View File

@ -166,10 +166,12 @@ class Menu extends Widget
$this->params = Yii::$app->request->getQueryParams(); $this->params = Yii::$app->request->getQueryParams();
} }
$items = $this->normalizeItems($this->items, $hasActiveChild); $items = $this->normalizeItems($this->items, $hasActiveChild);
if (!empty($items)) {
$options = $this->options; $options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'ul'); $tag = ArrayHelper::remove($options, 'tag', 'ul');
echo Html::tag($tag, $this->renderItems($items), $options); echo Html::tag($tag, $this->renderItems($items), $options);
} }
}
/** /**
* Recursively renders the menu items (without the container tag). * Recursively renders the menu items (without the container tag).