|
|
@ -48,6 +48,8 @@ class Dropdown extends Widget |
|
|
|
* - options: array, optional, the HTML attributes of the item. |
|
|
|
* - options: array, optional, the HTML attributes of the item. |
|
|
|
* - items: array, optional, the submenu items. The structure is the same as this property. |
|
|
|
* - items: array, optional, the submenu items. The structure is the same as this property. |
|
|
|
* Note that Bootstrap doesn't support dropdown submenu. You have to add your own CSS styles to support it. |
|
|
|
* Note that Bootstrap doesn't support dropdown submenu. You have to add your own CSS styles to support it. |
|
|
|
|
|
|
|
* - submenuOptions: array, optional, the HTML attributes for sub-menu container tag. If specified it will be |
|
|
|
|
|
|
|
* merged with [[submenuOptions]]. |
|
|
|
* |
|
|
|
* |
|
|
|
* To insert divider use `<li role="presentation" class="divider"></li>`. |
|
|
|
* To insert divider use `<li role="presentation" class="divider"></li>`. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -56,6 +58,12 @@ class Dropdown extends Widget |
|
|
|
* @var boolean whether the labels for header items should be HTML-encoded. |
|
|
|
* @var boolean whether the labels for header items should be HTML-encoded. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $encodeLabels = true; |
|
|
|
public $encodeLabels = true; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var array|null the HTML attributes for sub-menu container tags. |
|
|
|
|
|
|
|
* If not set - [[options]] value will be used for it. |
|
|
|
|
|
|
|
* @since 2.0.5 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $submenuOptions; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -64,6 +72,12 @@ class Dropdown extends Widget |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function init() |
|
|
|
public function init() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if ($this->submenuOptions === null) { |
|
|
|
|
|
|
|
// copying of [[options]] kept for BC |
|
|
|
|
|
|
|
// @todo separate [[submenuOptions]] from [[options]] completely before 2.1 release |
|
|
|
|
|
|
|
$this->submenuOptions = $this->options; |
|
|
|
|
|
|
|
unset($this->submenuOptions['id']); |
|
|
|
|
|
|
|
} |
|
|
|
parent::init(); |
|
|
|
parent::init(); |
|
|
|
Html::addCssClass($this->options, 'dropdown-menu'); |
|
|
|
Html::addCssClass($this->options, 'dropdown-menu'); |
|
|
|
} |
|
|
|
} |
|
|
@ -88,7 +102,7 @@ class Dropdown extends Widget |
|
|
|
protected function renderItems($items, $options = []) |
|
|
|
protected function renderItems($items, $options = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$lines = []; |
|
|
|
$lines = []; |
|
|
|
foreach ($items as $i => $item) { |
|
|
|
foreach ($items as $item) { |
|
|
|
if (isset($item['visible']) && !$item['visible']) { |
|
|
|
if (isset($item['visible']) && !$item['visible']) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
@ -113,8 +127,10 @@ class Dropdown extends Widget |
|
|
|
$content = Html::a($label, $url, $linkOptions); |
|
|
|
$content = Html::a($label, $url, $linkOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$submenuOptions = $options; |
|
|
|
$submenuOptions = $this->submenuOptions; |
|
|
|
unset($submenuOptions['id']); |
|
|
|
if (isset($item['submenuOptions'])) { |
|
|
|
|
|
|
|
$submenuOptions = array_merge($submenuOptions, $item['submenuOptions']); |
|
|
|
|
|
|
|
} |
|
|
|
$content = Html::a($label, $url === null ? '#' : $url, $linkOptions) |
|
|
|
$content = Html::a($label, $url === null ? '#' : $url, $linkOptions) |
|
|
|
. $this->renderItems($item['items'], $submenuOptions); |
|
|
|
. $this->renderItems($item['items'], $submenuOptions); |
|
|
|
Html::addCssClass($itemOptions, 'dropdown-submenu'); |
|
|
|
Html::addCssClass($itemOptions, 'dropdown-submenu'); |
|
|
|