mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Even better fix for #3443
This commit is contained in:
@ -56,16 +56,17 @@ class Dropdown extends Widget
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
echo $this->renderItems($this->items);
|
echo $this->renderItems($this->items, $this->options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders menu items.
|
* Renders menu items.
|
||||||
* @param array $items the menu items to be rendered
|
* @param array $items the menu items to be rendered
|
||||||
|
* @param array $containerOptions the HTML attributes for the widget container tag
|
||||||
* @return string the rendering result.
|
* @return string the rendering result.
|
||||||
* @throws InvalidConfigException if the label option is not specified in one of the items.
|
* @throws InvalidConfigException if the label option is not specified in one of the items.
|
||||||
*/
|
*/
|
||||||
protected function renderItems($items)
|
protected function renderItems($items, $containerOptions)
|
||||||
{
|
{
|
||||||
$lines = [];
|
$lines = [];
|
||||||
foreach ($items as $i => $item) {
|
foreach ($items as $i => $item) {
|
||||||
@ -87,8 +88,8 @@ class Dropdown extends Widget
|
|||||||
$linkOptions['tabindex'] = '-1';
|
$linkOptions['tabindex'] = '-1';
|
||||||
$content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
|
$content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions);
|
||||||
if (!empty($item['items'])) {
|
if (!empty($item['items'])) {
|
||||||
unset($this->options['id']);
|
unset($containerOptions['id']);
|
||||||
$this->renderItems($item['items']);
|
$this->renderItems($item['items'], $containerOptions);
|
||||||
Html::addCssClass($options, 'dropdown-submenu');
|
Html::addCssClass($options, 'dropdown-submenu');
|
||||||
}
|
}
|
||||||
$lines[] = Html::tag('li', $content, $options);
|
$lines[] = Html::tag('li', $content, $options);
|
||||||
|
Reference in New Issue
Block a user