encodeLabels; $label = $encodeLabel ? Html::encode($item['label']) : $item['label']; $options = ArrayHelper::getValue($item, 'options', []); $items = ArrayHelper::getValue($item, 'items'); $url = ArrayHelper::getValue($item, 'url', '#'); $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); if (isset($item['active'])) { $active = ArrayHelper::remove($item, 'active', false); } else { $active = $this->isItemActive($item); } if (empty($items)) { $items = ''; } else { $linkOptions['data-toggle'] = 'dropdown'; Html::addCssClass($options, ['widget' => 'dropdown']); Html::addCssClass($linkOptions, ['widget' => 'dropdown-toggle']); if ($this->dropDownCaret !== '') { $label .= ' ' . $this->dropDownCaret; } if (is_array($items)) { $items = $this->isChildActive($items, $active); $items = $this->renderDropdown($items, $item); } } if ($active) { Html::addCssClass($options, 'active'); } return ($url!=='')? Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options) : Html::tag('li', Html::a($label, null, $linkOptions) . $items, $options) ; } public function init() { foreach ($this->items as &$item) { if($item['url']===false)$item['url']=''; } if ($this->route === null && \Yii::$app->controller !== null) { $this->route = \Yii::$app->controller->getRoute(); } if ($this->params === null) { $this->params = \Yii::$app->request->getQueryParams(); } if ($this->dropDownCaret === null) { $this->dropDownCaret = ''; } Html::addCssClass($this->options, []); } }