Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 23 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T05:10:34.000Z (over 6 years ago)
- Last Synced: 2024-12-14T12:16:23.483Z (27 days ago)
- Topics: bootstrap, bootstrap-toggle, yii2, yii2-extension, yii2-widgets
- Language: PHP
- Homepage:
- Size: 61.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
yii2-bootstrap-toggle
===========[![Build Status](https://travis-ci.org/alexeevdv/yii2-bootstrap-toggle.svg?branch=master)](https://travis-ci.org/alexeevdv/yii2-bootstrap-toggle)
[![codecov](https://codecov.io/gh/alexeevdv/yii2-bootstrap-toggle/branch/master/graph/badge.svg)](https://codecov.io/gh/alexeevdv/yii2-bootstrap-toggle)
![PHP 5.6](https://img.shields.io/badge/PHP-5.6-green.svg)
![PHP 7.0](https://img.shields.io/badge/PHP-7.0-green.svg)
![PHP 7.1](https://img.shields.io/badge/PHP-7.1-green.svg)
![PHP 7.2](https://img.shields.io/badge/PHP-7.2-green.svg)Yii2 extension to render [bootstrap toggle](http://www.bootstraptoggle.com/) widget instead of checkbox.
![Screenshot](screenshot.jpg)
## 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' => [],
]);
```