yii\bootstrap\Tabs::renderDropdown PHP Method

renderDropdown() protected method

Normalizes dropdown item options by removing tab specific keys content and contentOptions, and also configure panes accordingly.
protected renderDropdown ( string $itemNumber, array &$items, array &$panes ) : boolean
$itemNumber string number of the item
$items array the dropdown items configuration.
$panes array the panes reference array.
return boolean whether any of the dropdown items is `active` or not.
    protected function renderDropdown($itemNumber, &$items, &$panes)
    {
        $itemActive = false;
        foreach ($items as $n => &$item) {
            if (is_string($item)) {
                continue;
            }
            if (isset($item['visible']) && !$item['visible']) {
                continue;
            }
            if (!(array_key_exists('content', $item) xor array_key_exists('url', $item))) {
                throw new InvalidConfigException("Either the 'content' or the 'url' option is required, but only one can be set.");
            }
            if (array_key_exists('url', $item)) {
                continue;
            }
            $content = ArrayHelper::remove($item, 'content');
            $options = ArrayHelper::remove($item, 'contentOptions', []);
            Html::addCssClass($options, ['widget' => 'tab-pane']);
            if (ArrayHelper::remove($item, 'active')) {
                Html::addCssClass($options, 'active');
                Html::addCssClass($item['options'], 'active');
                $itemActive = true;
            }
            $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd' . $itemNumber . '-tab' . $n);
            $item['url'] = '#' . $options['id'];
            if (!isset($item['linkOptions']['data-toggle'])) {
                $item['linkOptions']['data-toggle'] = 'tab';
            }
            $panes[] = Html::tag('div', $content, $options);
            unset($item);
        }
        return $itemActive;
    }