src/Tabs.php
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;
    }
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;
    }
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 ; }
Normalizes dropdown item options by removing tab specific keys `content` and `contentOptions`, and also
configure `panes` accordingly.
@param string $itemNumber number of the item
@param array $items the dropdown items configuration.
@param array $panes the panes reference array.
@return bool whether any of the dropdown items is `active` or not.
@throws InvalidConfigException
Normalizes dropdown item options by removing tab specific keys content and contentOptions and also configure panes accordingly .