kak/input-switch bootstrap switch for Yii2

bootstrap-switch

kak-input-switch

bootstrap-switch widget for Yii2

Documentation

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kak/input-switch "dev-master"

or add

"kak/input-switch": "dev-master"

to the require section of your composer.json file.

Usage

ActiveForm

echo $form->field($model, 'list')->widget('\kak\widgets\InputSwitch\InputSwitch', [
    'options' => [
        'data-id'   => $model->id,
        'data-size' => 'small'
    ],
]) ?>

Native

echo  \kak\widgets\InputSwitch\InputSwitch::widget([
    'name' => 'OperatorSwitch[' . $model->id . ']',
    'value' => $model->status == true,
    'options' => [
        'data-id'   => $model->id,
        'data-size' => 'small'
    ]
]);

Use Events

$js =<<<JS
   $('.InputSwitch').on('switchChange.bootstrapSwitch', function(event, state) {
      $.post('/finance/credit-operator-switch',{status: state, id: $(this).data('id') })
    });
JS;
$this->registerJs($js)
?>

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

No stable releases.

Comments



No stable releases.



MIT license
Stats
0 github stars & 1 github forks
0 downloads in the last day
5 downloads in the last 30 days
836 total downloads