Class yii\bootstrap4\ButtonGroup
| Inheritance | yii\bootstrap4\ButtonGroup » yii\bootstrap4\Widget » yii\base\Widget | 
|---|---|
| Uses Traits | yii\bootstrap4\BootstrapWidgetTrait | 
ButtonGroup renders a button group bootstrap component.
For example,
// a button group with items configuration
echo ButtonGroup::widget([
    'buttons' => [
        ['label' => 'A'],
        ['label' => 'B'],
        ['label' => 'C', 'visible' => false],
    ]
]);
// button group with an item as a string
echo ButtonGroup::widget([
    'buttons' => [
        Button::widget(['label' => 'A']),
        ['label' => 'B'],
    ]
]);
Pressing on the button should be handled via JavaScript. See the following for details:
See also:
Public Properties
| Property | Type | Description | Defined By | 
|---|---|---|---|
| $buttons | array | List of buttons. | yii\bootstrap4\ButtonGroup | 
| $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 | 
| $encodeLabels | boolean | Whether to HTML-encode the button labels. | yii\bootstrap4\ButtonGroup | 
| $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\ButtonGroup | 
| run() | yii\bootstrap4\ButtonGroup | 
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 | 
| renderButtons() | Generates the buttons that compound the group as specified on $buttons. | yii\bootstrap4\ButtonGroup | 
Property Details
List of buttons. Each array element represents a single button which can be specified as a string or an array of the following structure:
- label: string, required, the button label.
- options: array, optional, the HTML attributes of the button.
- visible: bool, optional, whether this button is visible. Defaults to true.
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 buttons that compound the group as specified on $buttons.
| protected string renderButtons ( ) | ||
| return | string | The rendering result. | 
|---|---|---|
| throws | Exception | |
| public void run ( ) | ||
| throws | Exception | |
|---|---|---|