How to make ActiveRecord mongodb gave, model, and array?

Use Yii extension mongodb, receive the data and render the grid. Similar as MySQL wanted to customize the value of the column, it turns out that by default, an anonymous function is passed is not the model, but just an array.
[
 'attribute' => 'type_id',
 'label' => 'List',
 'value' => function($model) { 
 return print_r($model, true); // here can not work as a model calling it a function
 } 
 ],


use yii\data\ActiveDataProvider;
use yii\mongodb\Query;


 $query = new Query();
 $query->from('tariffs')->where(['user_id' => $user->id]); 

 $dataProvider = new ActiveDataProvider([
 'query' => $query,
 'pagination' => [
 'pageSize' => 10,
]
 ]);
August 19th 19 at 22:42
1 answer
August 19th 19 at 22:44
Solution
it turns out that by default, an anonymous function is passed is not the model, but just an array.

In anaonimno transmitted the data that You have formed, in this case, You generate the data with the help of yii\mongodb\Query. Query is a normal query is not tied in any way to the objects. If you want to bind the query result to the object use yii\mongodb\ActiveQuery

Find more questions by tags MongoDBYii