Class yii\jui\Tabs

Inheritanceyii\jui\Tabs » yii\jui\Widget » yii\base\Widget
Available since version2.0

Tabs renders a tabs jQuery UI widget.

For example:

echo Tabs::widget([
    'items' => [
        [
            'label' => 'Tab one',
            'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...',
        ],
        [
            'label' => 'Tab two',
            'content' => 'Sed non urna. Phasellus eu ligula. Vestibulum sit amet purus...',
            'options' => ['tag' => 'div'],
            'headerOptions' => ['class' => 'my-class'],
        ],
        [
            'label' => 'Tab with custom id',
            'content' => 'Morbi tincidunt, dui sit amet facilisis feugiat...',
            'options' => ['id' => 'my-tab'],
        ],
        [
            'label' => 'Ajax tab',
            'url' => ['ajax/content'],
        ],
    ],
    'options' => ['tag' => 'div'],
    'itemOptions' => ['tag' => 'div'],
    'headerOptions' => ['class' => 'my-class'],
    'clientOptions' => ['collapsible' => false],
]);

See also http://api.jqueryui.com/tabs/.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$clientEvents array The event handlers for the underlying jQuery UI widget. yii\jui\Widget
$clientOptions array The options for the underlying jQuery UI widget. yii\jui\Widget
$encodeLabels boolean Whether the labels for header items should be HTML-encoded. yii\jui\Tabs
$headerOptions array List of HTML attributes for the header container tags. yii\jui\Tabs
$itemOptions array List of HTML attributes for the item container tags. yii\jui\Tabs
$items array List of tab items. yii\jui\Tabs
$linkTemplate string The default header template to render the link. yii\jui\Tabs
$options array The HTML attributes for the widget container tag. yii\jui\Tabs

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$clientEventMap array Event names mapped to what should be specified in `. yii\jui\Widget

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() Initializes the widget. yii\jui\Widget
run() Renders the widget. yii\jui\Tabs

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
registerClientEvents() Registers a specific jQuery UI widget events yii\jui\Widget
registerClientOptions() Registers a specific jQuery UI widget options yii\jui\Widget
registerWidget() Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events yii\jui\Widget
renderItems() Renders tab items as specified on $items. yii\jui\Tabs

Property Details

$encodeLabels public property

Whether the labels for header items should be HTML-encoded.

public boolean $encodeLabels true
$headerOptions public 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 array $headerOptions = []
$itemOptions public 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 array $itemOptions = []
$items public property

List of tab items. Each item can be an array of the following structure:

  • label: string, required, specifies the header link label. When $encodeLabels is true, the label will be HTML-encoded.
  • content: string, the content to show when corresponding tab is clicked. Can be omitted if url is specified.
  • url: mixed, mixed, optional, the url to load tab contents via AJAX. It is required if no content is specified.
  • template: string, optional, the header link template to render the header link. If none specified $linkTemplate will be used instead.
  • options: array, optional, the HTML attributes of the header.
  • headerOptions: array, optional, the HTML attributes for the header container tag.
public array $items = []
$linkTemplate public property

The default header template to render the link.

public string $linkTemplate '<a href="{url}">{label}</a>'
$options public property

The HTML attributes for the widget container tag. The following special options are recognized:

  • tag: string, defaults to "div", the tag name of the container tag of this widget.

See also \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.

public array $options = []

Method Details

renderItems() protected method

Renders tab items as specified on $items.

protected string renderItems ( )
return string

The rendering result.

throws \yii\jui\InvalidConfigException.
run() public method

Renders the widget.

public void run ( )