PHPackages                             hbhe/yii2-toggle-column - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hbhe/yii2-toggle-column

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

hbhe/yii2-toggle-column
=======================

Provides a toggle data column and action

2361PHP

Since Sep 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/hbhe/yii2-toggle-column)[ Packagist](https://packagist.org/packages/hbhe/yii2-toggle-column)[ RSS](/packages/hbhe-yii2-toggle-column/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Toggle data column for Yii2
===========================

[](#toggle-data-column-for-yii2)

Provides a toggle data column and action

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

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

```

or add

```
"hbhe/yii2-toggle-column": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

```
// Controller文件中
use hbhe\grid\actions\ToggleAction;

public function actions()
{
    return [
        'toggle-status' => [
            'class' => ToggleAction::className(),
            'onValue' => User::STATUS_ACTIVE,
            'offValue' => User::STATUS_NOT_ACTIVE,
            'modelClass' => 'common\models\User',
            'attribute' => 'status',
            // Uncomment to enable flash messages
            'setFlash' => true,
        ]
    ];
}

// View文件中
// Pjax::begin();
GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        'id',
        [
            'class' => '\hbhe\grid\ToggleColumn',
            'attribute' => 'status',
            'action' => 'toggle-status',
            'onText' => '禁用',
            'offText' => '启用',
            'displayValueText' => true,
            'onValueText' => '已禁用',
            'offValueText' => '已启用',
            'iconOn' => 'stop',
            'iconOff' => 'stop',
            'enableAjax' => false, // 使用pjax时要设为true
            'confirm' => function($model, $toggle) {
                if ($model->status == Member::STATUS_NOT_ACTIVE) {
                    return "确认启用: {$model->username}({$model->id})?";
                } else {
                    return "确认禁用: {$model->username}({$model->id})?";
                }
            },
            'headerOptions' => array('style' => 'width:80px;'),
        ],
    ],
]);

// Pjax::end();
```

[![截图](https://github.com/hbhe/yii2-toggle-column/raw/master/screenshot.png)](https://github.com/hbhe/yii2-toggle-column/blob/master/screenshot.png)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6417343?v=4)[hbhe](/maintainers/hbhe)[@hbhe](https://github.com/hbhe)

### Embed Badge

![Health badge](/badges/hbhe-yii2-toggle-column/health.svg)

```
[![Health](https://phpackages.com/badges/hbhe-yii2-toggle-column/health.svg)](https://phpackages.com/packages/hbhe-yii2-toggle-column)
```

###  Alternatives

[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8351.3M7](/packages/wapmorgan-morphos)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[hackzilla/password-generator

Password Generator Library

3035.2M15](/packages/hackzilla-password-generator)[alibaba/nacos

阿里巴巴nacos配置中心php客户端

19340.8k1](/packages/alibaba-nacos)[bvdputte/kirby-fingerprint

Cache-busting utility to fingerprint assets (JS/CSS) in Kirby 3

1610.0k](/packages/bvdputte-kirby-fingerprint)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
