yii2mod/yii2-toggle-column

提供切换数据列和操作功能

安装次数: 7,835

依赖者: 0

建议者: 0

安全性: 0

星标: 3

关注者: 3

分支: 1

开放性问题: 0

类型:yii2-extension

1.1 2017-03-05 16:31 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:50:10 UTC


README

Yii 2 切换列小部件


为 Yii Framework 2.0 提供切换数据列和操作功能

Latest Stable Version Total Downloads License Build Status

安装

安装此扩展的首选方式是通过 Composer

运行以下命令之一:

php composer.phar require --prefer-dist yii2mod/yii2-toggle-column "*"

"yii2mod/yii2-toggle-column": "*"

将以下内容添加到您的 composer.json 文件的 require 部分:

使用方法

  1. 在您的 GridView 列部分
[
    'class' => '\yii2mod\toggle\ToggleColumn',
    'attribute' => 'active',
],
  1. 按照以下方式在控制器中添加 切换操作
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
            }
        ],
    ];
}