Answer the question
In order to leave comments, you need to log in
Yii2: dataProvider how to format output?
In general, a subject.
I created a controller and a view in gii. In actionIndex the following code (everything is standard):
$dataProvider = new ActiveDataProvider(.......
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
$model->birdthday= date("d.m.Y", strtotime($model->birthday));
Answer the question
In order to leave comments, you need to log in
'columns' => [
[
'attribute' => 'name',
'format' => 'html',
'value' => function ($model) {
return Html::a(
'<img src="'.Media::preview($model->image_id,100,100).'" class="pull-left img-thumbnail" />'
. $model->name,
['/club/view', 'club_id'=>$model->id]
);
}
],
[
'attribute' => 'city_id',
'format' => 'html',
'value' => function ($model) {
return $model->city->name;
}
],
'members_count',
[
'attribute' => 'type',
'format' => 'text',
'value' => function ($model) {
return \app\models\Club::$types[ $model->type ];
}
],
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question