https://github.com/alexeevdv/yii2-bootstrap-toggle
Yii2 extension to render bootstrap toggle widget instead of checkbox.
https://github.com/alexeevdv/yii2-bootstrap-toggle
bootstrap bootstrap-toggle yii2 yii2-extension yii2-widgets
Last synced: 3 months ago
JSON representation
Yii2 extension to render bootstrap toggle widget instead of checkbox.
- Host: GitHub
- URL: https://github.com/alexeevdv/yii2-bootstrap-toggle
- Owner: alexeevdv
- License: mit
- Created: 2017-07-14T07:04:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T05:10:34.000Z (almost 7 years ago)
- Last Synced: 2025-03-11T06:54:35.549Z (4 months ago)
- Topics: bootstrap, bootstrap-toggle, yii2, yii2-extension, yii2-widgets
- Language: PHP
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
yii2-bootstrap-toggle
===========[](https://travis-ci.org/alexeevdv/yii2-bootstrap-toggle)
[](https://codecov.io/gh/alexeevdv/yii2-bootstrap-toggle)



Yii2 extension to render [bootstrap toggle](http://www.bootstraptoggle.com/) widget instead of checkbox.

## Installation
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).
Either run
```
$ php composer.phar require alexeevdv/yii2-bootstrap-toggle "~2.0"
```or add
```
"alexeevdv/yii2-bootstrap-toggle": "~2.0"
```to the ```require``` section of your `composer.json` file.
## Usage
### In active form
```php
use alexeevdv\yii\BootstrapToggleWidget;//...
echo $form->field($model, 'attribute')->widget(BootstrapToggleWidget::class);
//...
```### Standalone widget
```php
use alexeevdv\yii\BootstrapToggleWidget;//...
BootstrapToggleWidget::widget([
'name' => 'is_enabled',
'value' => false,
]);
//...
```## Options
```php
BootstrapToggleWidget::widget([
/**
* Wrapper tag name. If set to false no tag will be rendered
*/
'container' => 'div',/**
* Wrapper HTML attributes
*/
'containerOptions' => [],
/**
* Label when checkbox is checked
*/
'labelEnabled' => 'Yes',
/**
* Label when checkbox is not checked
*/
'labelDisabled' => 'No',
/**
* Value when checkbox is checked
*/
'valueEnabled' => '1',/**
* Value when checkbox is not checked
*/
'valueDisabled' => '0',
/**
* Additional javascript options to Bootstrap Toggle plugin
*/
'pluginOptions' => [],
]);
```