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