PHP Class yii\bootstrap\Tabs

For example: php echo Tabs::widget([ 'items' => [ [ 'label' => 'One', 'content' => 'Anim pariatur cliche...', 'active' => true ], [ 'label' => 'Two', 'content' => 'Anim pariatur cliche...', 'headerOptions' => [...], 'options' => ['id' => 'myveryownID'], ], [ 'label' => 'Example', 'url' => 'http://www.example.com', ], [ 'label' => 'Dropdown', 'items' => [ [ 'label' => 'DropdownA', 'content' => 'DropdownA, Anim pariatur cliche...', ], [ 'label' => 'DropdownB', 'content' => 'DropdownB, Anim pariatur cliche...', ], [ 'label' => 'External Link', 'url' => 'http://www.example.com', ], ], ], ], ]);
See also: http://getbootstrap.com/javascript/#tabs
Since: 2.0
Author: Antonio Ramirez ([email protected])
Inheritance: extends yii\bootstrap\Widget
显示文件 Open project: yiisoft/yii2-bootstrap Class Usage Examples

Public Properties

Property Type Description
$dropdownClass name of a class to use for rendering dropdowns withing this widget. Defaults to Dropdown.
$encodeLabels whether the labels for header items should be HTML-encoded.
$headerOptions list of HTML attributes for the header container tags. This will be overwritten by the "headerOptions" set in individual [[items]].
$itemOptions list of HTML attributes for the item container tags. This will be overwritten by the "options" set in individual [[items]]. The following special options are recognized: - tag: string, defaults to "div", the tag name of the item container tags.
$items list of tabs in the tabs widget. Each array element represents a single tab with the following structure: - label: string, required, the tab header label. - encode: boolean, optional, whether this label should be HTML-encoded. This param will override global $this->encodeLabels param. - headerOptions: array, optional, the HTML attributes of the tab header. - linkOptions: array, optional, the HTML attributes of the tab header link tags. - content: string, optional, the content (HTML) of the tab pane. - url: string, optional, an external URL. When this is specified, clicking on this tab will bring the browser to this URL. This option is available since version 2.0.4. - options: array, optional, the HTML attributes of the tab pane container. - active: boolean, optional, whether this item tab header and pane should be active. If no item is marked as 'active' explicitly - the first one will be activated. - visible: boolean, optional, whether the item tab header and pane should be visible or not. Defaults to true. - items: array, optional, can be used instead of content to specify a dropdown items configuration array. Each item can hold three extra keys, besides the above ones: * active: boolean, optional, whether the item tab header and pane should be visible or not. * content: string, required if items is not set. The content (HTML) of the tab pane. * contentOptions: optional, array, the HTML attributes of the tab content container.
$linkOptions list of HTML attributes for the tab header link tags. This will be overwritten by the "linkOptions" set in individual [[items]].
$navType specifies the Bootstrap tab styling.
$renderTabContent whether to render the tab-content container and its content. You may set this property to be false so that you can manually render tab-content yourself in case your tab contents are complex.

Public Methods

Method Description
init ( ) Initializes the widget.
run ( ) Renders the widget.

Protected Methods

Method Description
hasActiveTab ( ) : boolean
renderDropdown ( string $itemNumber, array &$items, array &$panes ) : boolean Normalizes dropdown item options by removing tab specific keys content and contentOptions, and also configure panes accordingly.
renderItems ( ) : string Renders tab items as specified on [[items]].

Method Details

hasActiveTab() protected method

protected hasActiveTab ( ) : boolean
return boolean if there's active tab defined

init() public method

Initializes the widget.
public init ( )

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.

renderItems() protected method

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

run() public method

Renders the widget.
public run ( )

Property Details

$dropdownClass public_oe property

name of a class to use for rendering dropdowns withing this widget. Defaults to Dropdown.
Since: 2.0.7
public $dropdownClass

$encodeLabels public_oe property

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

$headerOptions public_oe property

list of HTML attributes for the header container tags. This will be overwritten by the "headerOptions" set in individual [[items]].
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $headerOptions

$itemOptions public_oe property

list of HTML attributes for the item container tags. This will be overwritten by the "options" set in individual [[items]]. The following special options are recognized: - tag: string, defaults to "div", the tag name of the item container tags.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $itemOptions

$items public_oe property

list of tabs in the tabs widget. Each array element represents a single tab with the following structure: - label: string, required, the tab header label. - encode: boolean, optional, whether this label should be HTML-encoded. This param will override global $this->encodeLabels param. - headerOptions: array, optional, the HTML attributes of the tab header. - linkOptions: array, optional, the HTML attributes of the tab header link tags. - content: string, optional, the content (HTML) of the tab pane. - url: string, optional, an external URL. When this is specified, clicking on this tab will bring the browser to this URL. This option is available since version 2.0.4. - options: array, optional, the HTML attributes of the tab pane container. - active: boolean, optional, whether this item tab header and pane should be active. If no item is marked as 'active' explicitly - the first one will be activated. - visible: boolean, optional, whether the item tab header and pane should be visible or not. Defaults to true. - items: array, optional, can be used instead of content to specify a dropdown items configuration array. Each item can hold three extra keys, besides the above ones: * active: boolean, optional, whether the item tab header and pane should be visible or not. * content: string, required if items is not set. The content (HTML) of the tab pane. * contentOptions: optional, array, the HTML attributes of the tab content container.
public $items

$linkOptions public_oe property

list of HTML attributes for the tab header link tags. This will be overwritten by the "linkOptions" set in individual [[items]].
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $linkOptions

$navType public_oe property

specifies the Bootstrap tab styling.
public $navType

$renderTabContent public_oe property

whether to render the tab-content container and its content. You may set this property to be false so that you can manually render tab-content yourself in case your tab contents are complex.
Since: 2.0.1
public $renderTabContent