This widget will help to replace the checkbox in the form with a nice switch.
The preferred way to install this extension is through composer.
Either run
php composer.phar require "coderius/yii2-toggle-switcher-widget" "@dev"
or
composer require "coderius/yii2-toggle-switcher-widget" "@dev"
or add
"coderius/yii2-toggle-switcher-widget" : "@dev"
to the require section of your application's composer.json
file.
How to basic use widget:
<?php
echo $form->field($model, 'flagActive')->widget(ToggleSwitchWidget::classname(), [
'type' => ToggleSwitchWidget::CHECKBOX
]);
?>
Or more short notice (ToggleSwitchWidget::CHECKBOX is default type value in widget):
<?= $form->field($model, 'status')->widget(ToggleSwitchWidget::classname()); ?>
Comments