2017 © Pedro Peláez
 

yii2-extension yii2-switchery

switchery for yii2

image

yh/yii2-switchery

switchery for yii2

  • Wednesday, January 31, 2018
  • by pcyanglei
  • Repository
  • 1 Watchers
  • 0 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 30 % Grown

The README.md

switchery for yii2

switchery for yii2 images, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist yh/yii2-switchery "dev-master"

or add, (*4)

"yh/yii2-switchery": "dev-master"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by :, (*6)

view:, (*7)

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'tableOptions' => ['class' => 'table table-striped'],
    'columns' => [
        'id',
        'username',
        'email:email',
        'status',
        [
            'class'       => 'yh\switchery\Switchery',
            'attribute'   => 'status',
            'action'      => 'user/status',//发送ajax的地址
            'callBack'    => 'function(data){console.log(data)}',
            'statusOpen'  =>10,//default 10
            'statusClose' =>0//default 0
        ],
        'created_at:datetime',
        'updated_at:datetime',
    ],
]); ?>

controller:, (*8)

public function actionStatus($key,$status)
{
    \Yii::$app->getResponse()->format = 'json';
    $model = User::findOne($key);
    $model->status = $status;
    $model->save(false);
    return ['code' => 0,'message' => 'ok'];
}

The Versions

31/01 2018

dev-master

9999999-dev

switchery for yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Hu Yang

extension yii2 switchery