By default your model toggle attribute should be defined as boolean. If you want to toggle custom values see Advanced usage
Counfigure module in your app config as follow:
'modules' => [
'roundSwitch' => [
'class' => 'nickdenry\grid\toggle\Module',
],
]
Add following line to your GridView view
use nickdenry\grid\toggle\components\RoundSwitchColumn;
and setup your toggle attribute at GridView columns section
[
'class' => RoundSwitchColumn::class,
'attribute' => 'active',
/* other column options, i.e. */
'headerOptions' => ['width' => 150],
],
Add toggleAction to your Controller
use nickdenry\grid\toggle\actions\ToggleAction;
public function actions()
{
return [
'toggle' => [
'class' => ToggleAction::class,
'modelClass' => 'common\models\Model', // Your model class
],
];
}