Yii2 extension to render bootstrap toggle widget instead of checkbox.
http://www.bootstraptoggle.com/
The preferred way to install this extension is through composer.
Either run
$ php composer.phar require dbfernandes/yii2-icomp-toggle dev-master
or add
"dbfernandes/yii2-icomp-toggle": "dev-master"
to the require
section of your composer.json
file.
use dbfernandes\icomp\ICompToggleWidget;
//...
echo $form->field($model, 'attribute')->widget(ICompToggleWidget::className());
//...
use dbfernandes\icomp\ICompToggleWidget;
//...
IcompToggleWidget::widget([
'name' => 'is_enabled',
'value' => false,
]);
//...
ICompToggleWidget::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',
/**
* Additional javascript options to Bootstrap Toggle plugin
*/
'pluginOptions' => [],
]);