Class yii\bootstrap4\ButtonToolbar
| Inheritance | yii\bootstrap4\ButtonToolbar » yii\bootstrap4\Widget » yii\base\Widget | 
|---|---|
| Uses Traits | yii\bootstrap4\BootstrapWidgetTrait | 
ButtonToolbar Combines sets of button groups into button toolbars for more complex components.
Use utility classes as needed to space out groups, buttons, and more.
For example,
// a button toolbar with items configuration
echo ButtonToolbar::widget([
    'buttonGroups' => [
        [
            'buttons' => [
                ['label' => '1', 'class' => ['btn-secondary']],
                ['label' => '2', 'class' => ['btn-secondary']],
                ['label' => '3', 'class' => ['btn-secondary']],
                ['label' => '4', 'class' => ['btn-secondary']]
            ],
             'class' => ['mr-2']
        ],
        [
            'buttons' => [
                ['label' => '5', 'class' => ['btn-secondary']],
                ['label' => '6', 'class' => ['btn-secondary']],
                ['label' => '7', 'class' => ['btn-secondary']]
            ],
            'class' => ['mr-2']
        ],
        [
            'buttons' => [
                ['label' => '8', 'class' => ['btn-secondary']]
            ]
        ]
    ]
]);
Pressing on the button should be handled via JavaScript. See the following for details:
See also:
Public Properties
| Property | Type | Description | Defined By | 
|---|---|---|---|
| $buttonGroups | array | List of buttons groups. | yii\bootstrap4\ButtonToolbar | 
| $clientEvents | array | The event handlers for the underlying Bootstrap JS plugin. | yii\bootstrap4\BootstrapWidgetTrait | 
| $clientOptions | array | The options for the underlying Bootstrap JS plugin. | yii\bootstrap4\BootstrapWidgetTrait | 
| $options | array | The HTML attributes for the widget container tag. | yii\bootstrap4\Widget | 
Public Methods
| Method | Description | Defined By | 
|---|---|---|
| getView() | yii\bootstrap4\BootstrapWidgetTrait | |
| init() | Initializes the widget. | yii\bootstrap4\ButtonToolbar | 
| run() | yii\bootstrap4\ButtonToolbar | 
Protected Methods
| Method | Description | Defined By | 
|---|---|---|
| registerClientEvents() | Registers JS event handlers that are listed in $clientEvents. | yii\bootstrap4\BootstrapWidgetTrait | 
| registerPlugin() | Registers a specific Bootstrap plugin and the related events | yii\bootstrap4\BootstrapWidgetTrait | 
| renderButtonGroups() | Generates the button groups that compound the toolbar as specified on $buttonGroups. | yii\bootstrap4\ButtonToolbar | 
Property Details
List of buttons groups. Each array element represents a single group which can be specified as a string or an array of the following structure:
- buttons: array list of buttons. Either as array or string representation
- options: array optional, the HTML attributes of the button group.
- encodeLabels: bool whether to HTML-encode the button labels.
Method Details
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 ( ) | 
Generates the button groups that compound the toolbar as specified on $buttonGroups.
| protected string renderButtonGroups ( ) | ||
| return | string | The rendering result. | 
|---|---|---|
| throws | Exception | |
| public void run ( ) | ||
| throws | Exception | |
|---|---|---|