src/View/Helper/PanelHelper.php
public function create($title = null, $options = []) {

        if (is_array($title)) {
            $options = $title;
            $title   = null;
        }

        $out = '';

        // close previous panel if in group
        if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) {
            $out .= $this->end();
        }

        $options += [
            'body'     => true,
            'type'        => 'default',
            'collapsible' => $this->_states->is('group') ?
                $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'),
            'open'        => !$this->_states->is('group'),
            'panel-count' => $this->_panelCount,
            'title' => [],
            'templateVars' => []
        ];

        $this->_panelCount = intval($options['panel-count']) + 1;

        // check open
        $open = $options['open'];
        if ($this->_states->is('group')) {
            // increment count inside
            $this->_states->setValue('groupPanelCount',
                $this->_states->getValue('groupPanelCount') + 1);
            $open = $open
                || $this->_states->getValue('groupPanelOpen')
                    == $this->_states->getValue('groupPanelCount');
        }

        $out .= $this->formatTemplate('panelStart', [
            'type' => $options['type'],
            'attrs' => $this->templater()->formatAttributes(
                $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']),
            'templateVars' => $options['templateVars']
        ]);

        $this->_states->push('panel', [
            'part' => null,
            'bodyId' => 'collapse-'.$options['panel-count'],
            'headId' => 'heading-'.$options['panel-count'],
            'collapsible' => $options['collapsible'],
            'open' => $open,
            'inGroup' => $this->_states->is('group'),
            'groupId' => $this->_states->is('group') ?
                $this->_states->getValue('groupId') : 0
        ]);

        if (is_string($title) && $title) {
            $out .= $this->_createHeader($title, [
                'title' => $options['title']
            ]);
            if ($options['body']) {
                $out .= $this->_createBody();
            }
        }

        return $out;
    }
public function create($title = null, $options = []) {

        if (is_array($title)) {
            $options = $title;
            $title   = null;
        }

        $out = '';

        // close previous panel if in group
        if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) {
            $out .= $this->end();
        }

        $options += [
            'body'     => true,
            'type'        => 'default',
            'collapsible' => $this->_states->is('group') ?
                $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'),
            'open'        => !$this->_states->is('group'),
            'panel-count' => $this->_panelCount,
            'title' => [],
            'templateVars' => []
        ];

        $this->_panelCount = intval($options['panel-count']) + 1;

        // check open
        $open = $options['open'];
        if ($this->_states->is('group')) {
            // increment count inside
            $this->_states->setValue('groupPanelCount',
                $this->_states->getValue('groupPanelCount') + 1);
            $open = $open
                || $this->_states->getValue('groupPanelOpen')
                    == $this->_states->getValue('groupPanelCount');
        }

        $out .= $this->formatTemplate('panelStart', [
            'type' => $options['type'],
            'attrs' => $this->templater()->formatAttributes(
                $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']),
            'templateVars' => $options['templateVars']
        ]);

        $this->_states->push('panel', [
            'part' => null,
            'bodyId' => 'collapse-'.$options['panel-count'],
            'headId' => 'heading-'.$options['panel-count'],
            'collapsible' => $options['collapsible'],
            'open' => $open,
            'inGroup' => $this->_states->is('group'),
            'groupId' => $this->_states->is('group') ?
                $this->_states->getValue('groupId') : 0
        ]);

        if (is_string($title) && $title) {
            $out .= $this->_createHeader($title, [
                'title' => $options['title']
            ]);
            if ($options['body']) {
                $out .= $this->_createBody();
            }
        }

        return $out;
    }
public function create ( $ title = null , $ options = [ ] ) { if ( is_array ( $ title ) ) { $ options = $ title ; $ title = null ; } $ out = '' ; // close previous panel if in group if ( $ this -> _states -> is ( 'panel' ) && $ this -> _states -> getValue ( 'inGroup' ) ) { $ out .= $ this -> end ( ) ; } $ options += [ 'body' => true , 'type' => 'default' , 'collapsible' => $ this -> _states -> is ( 'group' ) ? $ this -> _states -> getValue ( 'groupCollapsible' ) : $ this -> getConfig ( 'collapsible' ) , 'open' => ! $ this -> _states -> is ( 'group' ) , 'panel-count' => $ this -> _panelCount , 'title' => [ ] , 'templateVars' => [ ] ] ; $ this -> _panelCount = intval ( $ options [ 'panel-count' ] ) + 1 ; // check open $ open = $ options [ 'open' ] ; if ( $ this -> _states -> is ( 'group' ) ) { // increment count inside $ this -> _states -> setValue ( 'groupPanelCount' , $ this -> _states -> getValue ( 'groupPanelCount' ) + 1 ) ; $ open = $ open || $ this -> _states -> getValue ( 'groupPanelOpen' ) == $ this -> _states -> getValue ( 'groupPanelCount' ) ; } $ out .= $ this -> formatTemplate ( 'panelStart' , [ 'type' => $ options [ 'type' ] , 'attrs' => $ this -> templater ( ) -> formatAttributes ( $ options , [ 'body' , 'type' , 'collapsible' , 'open' , 'panel-count' , 'title' ] ) , 'templateVars' => $ options [ 'templateVars' ] ] ) ; $ this -> _states -> push ( 'panel' , [ 'part' => null , 'bodyId' => 'collapse-' . $ options [ 'panel-count' ] , 'headId' => 'heading-' . $ options [ 'panel-count' ] , 'collapsible' => $ options [ 'collapsible' ] , 'open' => $ open , 'inGroup' => $ this -> _states -> is ( 'group' ) , 'groupId' => $ this -> _states -> is ( 'group' ) ? $ this -> _states -> getValue ( 'groupId' ) : 0 ] ) ; if ( is_string ( $ title ) && $ title ) { $ out .= $ this -> _createHeader ( $ title , [ 'title' => $ options [ 'title' ] ] ) ; if ( $ options [ 'body' ] ) { $ out .= $ this -> _createBody ( ) ; } } return $ out ; }
Open a panel.

If `$title` is a string, the panel header is created using `$title` as its
content and default options (except for the `title` options that can be specified
inside `$options`).

```php
echo $this->Panel->create('My Panel Title', ['title' => ['tag' => 'h2']]);
```

If the panel header is created, the panel body is automatically opened after
it, except if the `no-body` options is specified (see below).

If `$title` is an array, it is used as `$options`.

```php
echo $this->Panel->create(['class' => 'my-panel-class']);
```

If the `create()` method is used inside a panel group, the previous panel is
automatically closed.

### Options

- `collapsible` Set to `true` if the panel should be collapsible. Default is fetch
from configuration/
- `body` If `$title` is a string, set to `false` to not open the body after the
panel header. Default is `true`.
- `open` Indicate if the panel should be open. If the panel is not inside a group, the
default is `true`, otherwize the default is `false` and the panel is open if its
count matches the specified value in `startGroup()` (set to `true` inside a group to
force the panel to be open).
- `panel-count` Panel counter, can be used to override the default counter when inside
a group. This value is used to generate the panel, header and body ID attribute.
- `title` Array of options for the title. Default is [].
- `type` Type of the panel (`'default'`, `'primary'`, ...). Default is `'default'`.
- Other options will be passed to the `Html::div` method for creating the
panel `<div>`.

@param array|string $title   The panel title or an array of options.
@param array        $options Array of options. See above.

@return string An HTML string containing opening elements for a panel.
Open a panel .