PHP Class yii\bootstrap\Collapse

For example: php echo Collapse::widget([ 'items' => [ equivalent to the above [ 'label' => 'Collapsible Group Item #1', 'content' => 'Anim pariatur cliche...', open its content by default 'contentOptions' => ['class' => 'in'] ], another group item [ 'label' => 'Collapsible Group Item #1', 'content' => 'Anim pariatur cliche...', 'contentOptions' => [...], 'options' => [...], ], if you want to swap out .panel-body with .list-group, you may use the following [ 'label' => 'Collapsible Group Item #1', 'content' => [ 'Anim pariatur cliche...', 'Anim pariatur cliche...' ], 'contentOptions' => [...], 'options' => [...], 'footer' => 'Footer' // the footer label in list-group ], ] ]);
See also: http://getbootstrap.com/javascript/#collapse
Since: 2.0
Author: Antonio Ramirez ([email protected])
Inheritance: extends yii\bootstrap\Widget
Show file Open project: yiisoft/yii2-bootstrap Class Usage Examples

Public Properties

Property Type Description
$encodeLabels whether the labels for header items should be HTML-encoded.
$items list of groups in the collapse widget. Each array element represents a single group with the following structure: - label: string, required, the group header label. - encode: boolean, optional, whether this label should be HTML-encoded. This param will override global $this->encodeLabels param. - content: array|string|object, required, the content (HTML) of the group - options: array, optional, the HTML attributes of the group - contentOptions: optional, the HTML attributes of the group's content

Public Methods

Method Description
init ( ) Initializes the widget.
renderItem ( string $header, array $item, integer $index ) : string Renders a single collapsible item group
renderItems ( ) : string Renders collapsible items as specified on [[items]].
run ( ) Renders the widget.

Method Details

init() public method

Initializes the widget.
public init ( )

renderItem() public method

Renders a single collapsible item group
public renderItem ( string $header, array $item, integer $index ) : string
$header string a label of the item group [[items]]
$item array a single item from [[items]]
$index integer the item index as each item group content must have an id
return string the rendering result

renderItems() public method

Renders collapsible items as specified on [[items]].
public renderItems ( ) : string
return string the rendering result

run() public method

Renders the widget.
public run ( )

Property Details

$encodeLabels public property

whether the labels for header items should be HTML-encoded.
public $encodeLabels

$items public property

list of groups in the collapse widget. Each array element represents a single group with the following structure: - label: string, required, the group header label. - encode: boolean, optional, whether this label should be HTML-encoded. This param will override global $this->encodeLabels param. - content: array|string|object, required, the content (HTML) of the group - options: array, optional, the HTML attributes of the group - contentOptions: optional, the HTML attributes of the group's content
public $items