dev-master
9999999-devbootstrap switch for Yii2
MIT
The Requires
- yiisoft/yii2 *
- bower-asset/bootstrap-switch >=3.3.2
by Tutik Alexsandr
yii2 bootstrap-switch
bootstrap switch for Yii2
bootstrap-switch widget for Yii2, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist kak/input-switch "dev-master"
or add, (*4)
"kak/input-switch": "dev-master"
to the require section of your composer.json
file., (*5)
ActiveForm, (*6)
echo $form->field($model, 'list')->widget('\kak\widgets\InputSwitch\InputSwitch', [ 'options' => [ 'data-id' => $model->id, 'data-size' => 'small' ], ]) ?>
Native, (*7)
echo \kak\widgets\InputSwitch\InputSwitch::widget([ 'name' => 'OperatorSwitch[' . $model->id . ']', 'value' => $model->status == true, 'options' => [ 'data-id' => $model->id, 'data-size' => 'small' ] ]);
Use Events, (*8)
$js =<<<JS $('.InputSwitch').on('switchChange.bootstrapSwitch', function(event, state) { $.post('/finance/credit-operator-switch',{status: state, id: $(this).data('id') }) }); JS; $this->registerJs($js) ?>
bootstrap switch for Yii2
MIT
yii2 bootstrap-switch