这是我的查看页面view.php
<div class="dataTables_wrapper form-inline dt-bootstrap">
<?= GridView::widget([
'dataProvider' => $dataProvider1,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'label' =>'Date',
'value' => 'date',
],
[
'label' =>'Reminder',
'value' => function($model){
return Yii::$app->session->get('').' '.$model['type'].' '.'reminder';
}
],
[
'label' =>'To',
'value' => 'recipients',
],
]
]); ?>
</div>
这是控制者
$dataProvider1 = new ActiveDataProvider([
'query' => DomainReminders::find()
->where(['domain_id'=>$model['id']])
]);
$totalCount = $dataProvider1->getTotalCount();
return $this->renderAjax('view', [
'totalCount' => $totalCount,
'dataProvider' => $dataProvider,
'dataProvider1' => $dataProvider1,
true,
true
);
这是列名称为'type'的数据库,我希望在网格视图中像第一个提醒,第二个提醒,第三个提醒一样打印
现在这是我要打印的输出,如第一,第二提醒
答案 0 :(得分:3)
您可以为此使用Inflector::ordinalize()
:
[
'label' => 'Reminder',
'value' => function ($model) {
return Inflector::ordinalize($model['type']) . ' reminder';
},
],