Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.01 KB

configuration.md

File metadata and controls

54 lines (42 loc) · 1.01 KB

Configuration

Note

By default your model toggle attribute should be defined as boolean. If you want to toggle custom values see Advanced usage

1. Module config

Counfigure module in your app config as follow:

'modules' => [
    'roundSwitch' => [
        'class' => 'nickdenry\grid\toggle\Module',
    ],
]

2. GridView config

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],
],

3. Controller config

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
        ],
    ];
}