dev-master
9999999-dev https://github.com/porcelanosa/yii2-toggle-columnYii2 Extenstion for set seo attributes
MIT
The Requires
- php >=5.4.0
- yiisoft/yii2 *
by Alex Porcelanosa
yii2 yii yii 2 gridview gridview column
Yii2 Extenstion for set seo attributes
composer require porcelanosa/yii2-toggle-column
In controller file add action, (*1)
use porcelanosa\yii2togglecolumn\ToggleAction; use app\models\Artists; class ArtistsController extends Controller { //............. public function actions() { return [ 'toggle' => [ 'class' => ToggleAction::className(), 'modelClass' => Artists::className(), // Uncomment to enable flash messages //'setFlash' => true, 'attribute' => 'active', 'primaryKey' => 'id' ], ] } //....... }
I view file add column to the GridView, (*2)
= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ *['class' => 'yii\grid\SerialColumn'], 'id', [ 'class' => 'app\modules\admin\components\columns\ToggleColumn', 'attribute' => 'active', // Uncomment if you don't want AJAX 'enableAjax' => true, 'contentOptions' => ['style' => 'width:50px;'] ], ['class' => ActionColumn::className()], ], ]); ?>
, (*3)
Yii2 Extenstion for set seo attributes
MIT
yii2 yii yii 2 gridview gridview column