antonyz89/yii2-toggle-column

Installs: 448

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Type:yii2-extension

1.0.0 2022-01-07 04:03 UTC

This package is auto-updated.

Last update: 2024-05-07 08:49:33 UTC


README

Donate with PayPal

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist antonyz89/yii2-toggle-column dev-main
composer require antonyz89/yii2-toggle-column dev-main

or add

"antonyz89/yii2-toggle-column": "dev-main"

to the require section of your composer.json file.

USAGE

⚠️ In some cases you may need to add /toggle-column/parse/save to your urlManager.

common/config/main.php

use antonyz89\togglecolumn\Module as ToggleColumnModule;
use yii\i18n\PhpMessageSource;

return [
    // ...
    'modules' => [
        'toggle-column' => [
            'class' => ToggleColumnModule::class,
        ],
    ],
    'i18n' => [
        'translations' => [
            'tc' => [ // Toggle Column
                'class' => PhpMessageSource::class,
                'basePath' => '@antonyz89/togglecolumn/messages',
            ],
        ],
    ],
    // ...
];

After you downloaded, the last thing you need to do is updating your database schema by applying the migration:

$ php yii migrate/up --migrationPath=@antonyz89/togglecolumns/migrations

or copy the file migrations/m220105_225647_create_toggle_column_table.php to your console/migrations directory.

Example

<?php

$columns = [
    'code',
    [
        'attribute' => 'partner_id',
        'value' => 'partner',
        'visible' => false // will not be displayed in ToggleColumn widget either
    ],
    [
        'attribute' => 'customer',
    ],
    [
        'attribute' => 'status',
        'value' => 'statusAsText'
    ],
];

?>

<?=
GridView::widget([
    // ...
    'toolbar' => [
        ToggleColumn::widget([
            'model' => Reserve::class,
            'columns' => $columns,
        ]),
    ],
    // ...
])
?>