How to add a class to tags in a GridView

For example [ ‘attribute’ => ‘name’, ‘contentOptions’ => [‘class’ => ‘text-center’], ‘headerOptions’ => [‘class’ => ‘text-center’] ], contentOptions – for td cells, headerOptions – for th cells Reference: Yii2 Docs | Column classes in GridView

Yii2 – ActiveRecord to Array

Try this! $model = Post::find($id)->limit(10)->asArray()->all(); $model = Post::find($id)->select(‘id,name as full’)->asArray()->one(); $model = Post::find($id)->select(‘id,name as full’)->asArray()->all(); $model = Post::find()->where([‘slug’=>$slug])->asArray()->one();