Skip to content

Dropdown divider for a tab item #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Tabs extends Widget
* * active: bool, optional, whether the item tab header and pane should be visible or not.
* * content: string, required if `items` is not set. The content (HTML) of the tab pane.
* * options: optional, array, the HTML attributes of the tab content container.
*
*
* You can also passing string, specially for `-` character, it would render `divider` like in `yii\bootstrap5\Dropdown`
*/
public $items = [];
/**
Expand Down Expand Up @@ -194,6 +197,16 @@ protected function prepareItems(array &$items, string $prefix = ''): void
}

foreach ($items as $n => $item) {

if (is_string($item)) {
if ($item === '-') {
// Don't add divider to panes (tab-content)
continue;
}
$this->panes[] = $item;
continue;
}

$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', []));
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . $prefix . '-tab' . $n);
unset($items[$n]['options']['id']); // @see https://github.com/yiisoft/yii2-bootstrap4/issues/108#issuecomment-465219339
Expand Down
Loading