PHP code example of yii2mod / yii2-toggle-column

1. Go to this page and download the library: Download yii2mod/yii2-toggle-column library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yii2mod / yii2-toggle-column example snippets


[
    'class' => '\yii2mod\toggle\ToggleColumn',
    'attribute' => 'active',
],

public function actions()
{
   return [
        'toggle' => [
            'class' => \yii2mod\toggle\actions\ToggleAction::class,
            'modelClass' => 'path\to\your\Model',
            // if you want to use flash messages
            'setFlash' => true,
            'flashSuccess' => 'Success message',
            'flashError' => 'Error message',
            'redirect' => 'some-redirect-url',
            // if you want to use custom code before saving the model
            'preProcess' => function() {
                // your custom code
            }
        ],
    ];
}

php composer.phar