dev-master
9999999-devswitchery for yii2
BSD-3-Clause
The Requires
- yiisoft/yii2 ~2.0.0
- bower-asset/switchery >=0.8.0
by Hu Yang
extension yii2 switchery
Wallogit.com
2017 © Pedro Peláez
switchery for yii2
switchery for yii2
, (*1)
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)
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'];
}
switchery for yii2
BSD-3-Clause
extension yii2 switchery