Bootstrap-checkbox widget for Yii 2
This extension provides the Bootstrap-checkbox integration for the Yii2 framework.
Installation
This extension requires Bootstrap-checkbox
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist loveorigami/yii2-bootstrap-checkbox "*"
or add
"loveorigami/yii2-bootstrap-checkbox": "*"
to the require section of your composer.json.
General Usage
use lo\widgets\Checkbox;
Checkbox::widget(
[
'name' => 'status', // input name. Either 'name', or 'model' and 'attribute' properties must be specified.
'value' => 0, // 1 - checked
'options' => [], // checkbox options. More data html options see here http://vsn4ik.github.io/bootstrap-checkbox
]
)
or with active form as
<?= $form->field($model, 'status')->widget(Checkbox::className(),
[
options =>[
'id' => 'my-id',
'data-style' => 'btn-group-sm'
]
]
); ?>