Class yii\bootstrap4\ToggleButtonGroup
Inheritance | yii\bootstrap4\ToggleButtonGroup » yii\bootstrap4\InputWidget » yii\widgets\InputWidget |
---|---|
Uses Traits | yii\bootstrap4\BootstrapWidgetTrait |
ToggleButtonGroup allows rendering form inputs Checkbox/Radio toggle button groups.
You can use this widget in an \yii\bootstrap4\yii\bootstrap4\ActiveForm using the \yii\bootstrap4\yii\widgets\ActiveField::widget() method, for example like this:
<?= $form->field($model, 'item_id')->widget(\yii\bootstrap4\ToggleButtonGroup::class, [
'type' => \yii\bootstrap4\ToggleButtonGroup::TYPE_CHECKBOX
'items' => [
'fooValue' => 'BarLabel',
'barValue' => 'BazLabel'
]
]) ?>
See also http://getbootstrap.com/javascript/#buttons-checkbox-radio.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$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 the items labels should be HTML-encoded. | yii\bootstrap4\ToggleButtonGroup |
$items | array | The data item used to generate the checkboxes. | yii\bootstrap4\ToggleButtonGroup |
$labelOptions | \yii\bootstrap4\array, | The HTML attributes for the label (button) tag. | yii\bootstrap4\ToggleButtonGroup |
$type | string | Input type, can be TYPE_CHECKBOX or TYPE_RADIO | yii\bootstrap4\ToggleButtonGroup |
Public Methods
Method | Description | Defined By |
---|---|---|
getView() | yii\bootstrap4\BootstrapWidgetTrait | |
init() | Initializes the widget. | yii\bootstrap4\ToggleButtonGroup |
renderItem() | Default callback for checkbox/radio list item rendering. | yii\bootstrap4\ToggleButtonGroup |
run() | yii\bootstrap4\ToggleButtonGroup |
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 |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
TYPE_CHECKBOX | 'checkbox' | Checkbox type | yii\bootstrap4\ToggleButtonGroup |
TYPE_RADIO | 'radio' | Radio type | yii\bootstrap4\ToggleButtonGroup |
Property Details
Whether the items labels should be HTML-encoded.
The data item used to generate the checkboxes. The array values are the labels, while the array keys are the corresponding checkbox or radio values.
The HTML attributes for the label (button) tag.
See also:
- yii\bootstrap4\Html::checkbox()
- yii\bootstrap4\Html::radio()
Input type, can be TYPE_CHECKBOX or TYPE_RADIO
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 ( ) |
Default callback for checkbox/radio list item rendering.
See also:
- yii\bootstrap4\Html::checkbox()
- yii\bootstrap4\Html::radio()
public string renderItem ( $index, $label, $name, $checked, $value ) | ||
$index | integer | Item index. |
$label | string | Item label. |
$name | string | Input name. |
$checked | boolean | Whether value is checked or not. |
$value | string | Input value. |
return | string | Generated HTML. |
---|
public void run ( ) | ||
throws | \yii\base\InvalidConfigException |
---|