public function renderItem($item, $index)
    {
        $header = $item['label'];
        if (array_key_exists('content', $item)) {
            $id = $this->options['id'] . '-collapse-' . $index;
            $options = ArrayHelper::getValue($item, 'contentOptions', []);
            $options['id'] = $id;
            Html::addCssClass($options, ['widget' => 'collapse']);

            $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
            if ($encodeLabel) {
                $header = $this->htmlHlp->encode($header);
            }

            $headerOptions = [
                'class' => 'collapse-toggle',
                'data-toggle' => 'collapse',
            ];

            $headerToggle = $this->htmlHlp->a($header, '#' . $id, $headerOptions) . "\n";

            if (is_string($item['content']) || is_numeric($item['content']) || is_object($item['content'])) {
                $content = $this->htmlHlp->tag('div', $item['content'], ['class' => 'card-body']) . "\n";
            } elseif (is_array($item['content'])) {
                $content = $this->htmlHlp->ul($item['content'], [
                    'class' => 'list-group list-group-flush',
                    'itemOptions' => [
                        'class' => 'list-group-item'
                    ],
                    'encode' => false,
                ]) . "\n";
            } else {
                throw new InvalidConfigException('The "content" option should be a string, array or object.');
            }
        } else {
            throw new InvalidConfigException('The "content" option is required.');
        }

        if ($this->autoCloseItems) {
            $options['data-parent'] = '#' . $this->options['id'];
        }
        $contentCollapse = $this->htmlHlp->tag('div', $content, $options);

        $cardConfig = [
            'app' => $this->app,
            'options' => [
                'id' => $this->id . '-collapse-card-' . $index,
            ],
            'body' => $contentCollapse,
            'bodyOptions' => null,
            'header' => $headerToggle,
            'footer' => isset($item['footer']) ? $item['footer'] : null,
        ];

        return Card::widget($cardConfig);
    }
public function renderItem($item, $index)
    {
        $header = $item['label'];
        if (array_key_exists('content', $item)) {
            $id = $this->options['id'] . '-collapse-' . $index;
            $options = ArrayHelper::getValue($item, 'contentOptions', []);
            $options['id'] = $id;
            Html::addCssClass($options, ['widget' => 'collapse']);

            $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
            if ($encodeLabel) {
                $header = $this->htmlHlp->encode($header);
            }

            $headerOptions = [
                'class' => 'collapse-toggle',
                'data-toggle' => 'collapse',
            ];

            $headerToggle = $this->htmlHlp->a($header, '#' . $id, $headerOptions) . "\n";

            if (is_string($item['content']) || is_numeric($item['content']) || is_object($item['content'])) {
                $content = $this->htmlHlp->tag('div', $item['content'], ['class' => 'card-body']) . "\n";
            } elseif (is_array($item['content'])) {
                $content = $this->htmlHlp->ul($item['content'], [
                    'class' => 'list-group list-group-flush',
                    'itemOptions' => [
                        'class' => 'list-group-item'
                    ],
                    'encode' => false,
                ]) . "\n";
            } else {
                throw new InvalidConfigException('The "content" option should be a string, array or object.');
            }
        } else {
            throw new InvalidConfigException('The "content" option is required.');
        }

        if ($this->autoCloseItems) {
            $options['data-parent'] = '#' . $this->options['id'];
        }
        $contentCollapse = $this->htmlHlp->tag('div', $content, $options);

        $cardConfig = [
            'app' => $this->app,
            'options' => [
                'id' => $this->id . '-collapse-card-' . $index,
            ],
            'body' => $contentCollapse,
            'bodyOptions' => null,
            'header' => $headerToggle,
            'footer' => isset($item['footer']) ? $item['footer'] : null,
        ];

        return Card::widget($cardConfig);
    }
public function renderItem ( $ item , $ index ) { $ header = $ item [ 'label' ] ; if ( array_key_exists ( 'content' , $ item ) ) { $ id = $ this -> options [ 'id' ] . '-collapse-' . $ index ; $ options = ArrayHelper :: getValue ( $ item , 'contentOptions' , [ ] ) ; $ options [ 'id' ] = $ id ; Html :: addCssClass ( $ options , [ 'widget' => 'collapse' ] ) ; $ encodeLabel = isset ( $ item [ 'encode' ] ) ? $ item [ 'encode' ] : $ this -> encodeLabels ; if ( $ encodeLabel ) { $ header = $ this -> htmlHlp -> encode ( $ header ) ; } $ headerOptions = [ 'class' => 'collapse-toggle' , 'data-toggle' => 'collapse' , ] ; $ headerToggle = $ this -> htmlHlp -> a ( $ header , '#' . $ id , $ headerOptions ) . "\n" ; if ( is_string ( $ item [ 'content' ] ) || is_numeric ( $ item [ 'content' ] ) || is_object ( $ item [ 'content' ] ) ) { $ content = $ this -> htmlHlp -> tag ( 'div' , $ item [ 'content' ] , [ 'class' => 'card-body' ] ) . "\n" ; } elseif ( is_array ( $ item [ 'content' ] ) ) { $ content = $ this -> htmlHlp -> ul ( $ item [ 'content' ] , [ 'class' => 'list-group list-group-flush' , 'itemOptions' => [ 'class' => 'list-group-item' ] , 'encode' => false , ] ) . "\n" ; } else { throw new InvalidConfigException ( 'The "content" option should be a string, array or object.' ) ; } } else { throw new InvalidConfigException ( 'The "content" option is required.' ) ; } if ( $ this -> autoCloseItems ) { $ options [ 'data-parent' ] = '#' . $ this -> options [ 'id' ] ; } $ contentCollapse = $ this -> htmlHlp -> tag ( 'div' , $ content , $ options ) ; $ cardConfig = [ 'app' => $ this -> app , 'options' => [ 'id' => $ this -> id . '-collapse-card-' . $ index , ] , 'body' => $ contentCollapse , 'bodyOptions' => null , 'header' => $ headerToggle , 'footer' => isset ( $ item [ 'footer' ] ) ? $ item [ 'footer' ] : null , ] ; return Card :: widget ( $ cardConfig ) ; }
Renders a single collapsible item group
@param string $header a label of the item group [[items]]
@param array $item a single item from [[items]]
@param int $index the item index as each item group content must have an id
@return string the rendering result
@throws InvalidConfigException
Renders a single collapsible item group