yii\bootstrap\BootstrapWidgetTrait - Yii2 类参考手册

Trait yii\bootstrap\BootstrapWidgetTrait

Implemented byyii\apidoc\templates\bootstrap\SideNavWidget, yii\bootstrap\Alert, yii\bootstrap\Button, yii\bootstrap\ButtonDropdown, yii\bootstrap\ButtonGroup, yii\bootstrap\Carousel, yii\bootstrap\Collapse, yii\bootstrap\Dropdown, yii\bootstrap\InputWidget, yii\bootstrap\Modal, yii\bootstrap\Nav, yii\bootstrap\NavBar, yii\bootstrap\Progress, yii\bootstrap\Tabs, yii\bootstrap\ToggleButtonGroup, yii\bootstrap\Widget
Available since version2.0.6

BootstrapWidgetTrait is the trait, which provides basic for all bootstrap widgets features.

Note: class, which uses this trait must declare public field named options with the array default value:

class MyWidget extends \yii\base\Widget
{
    use BootstrapWidgetTrait;

    public $options = [];
}

This field is not present in the trait in order to avoid possible PHP Fatal error on definition conflict.

Public Properties

隐藏继承的属性 Hide inherited properties

属性Property类型 Type简介 Description定义在 Defined By
$clientEvents array The event handlers for the underlying Bootstrap JS plugin. yii\bootstrap\BootstrapWidgetTrait
$clientOptions array The options for the underlying Bootstrap JS plugin. yii\bootstrap\BootstrapWidgetTrait

Public Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
getView() yii\bootstrap\BootstrapWidgetTrait
init() Initializes the widget. yii\bootstrap\BootstrapWidgetTrait

Protected Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
registerClientEvents() Registers JS event handlers that are listed in $clientEvents. yii\bootstrap\BootstrapWidgetTrait
registerPlugin() Registers a specific Bootstrap plugin and the related events yii\bootstrap\BootstrapWidgetTrait

属性详情 Property Details

$clientEvents public property

The event handlers for the underlying Bootstrap JS plugin. Please refer to the corresponding Bootstrap plugin Web page for possible events. For example, this page shows how to use the "Modal" plugin and the supported events (e.g. "shown").

public array $clientEvents = []
$clientOptions public property

The options for the underlying Bootstrap JS plugin. Please refer to the corresponding Bootstrap plugin Web page for possible options. For example, this page shows how to use the "Modal" plugin and the supported options (e.g. "remote").

public array $clientOptions = []

方法详情 Method Details

getView() public abstract method
public abstract yii\web\View getView ( )
return yii\web\View

The view object that can be used to render views or view files.

init() public method

Initializes the widget.

This method will register the bootstrap asset bundle. If you override this method, make sure you call the parent implementation first.

public void init ( )
registerClientEvents() protected method (available since version 2.0.2)

Registers JS event handlers that are listed in $clientEvents.

protected void registerClientEvents ( )
registerPlugin() protected method

Registers a specific Bootstrap plugin and the related events

protected void registerPlugin ( $name )
$name string

The name of the Bootstrap plugin