guild/backend/modules/questionnaire/views/answer/index.php

66 lines
2.1 KiB
PHP
Raw Normal View History

2021-10-22 17:02:28 +03:00
<?php
2021-11-08 12:41:39 +03:00
use backend\modules\questionnaire\models\Question;
use backend\modules\questionnaire\models\Questionnaire;
2021-11-08 12:41:39 +03:00
use common\helpers\AnswerHelper;
use common\helpers\StatusHelper;
2021-10-22 17:02:28 +03:00
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\questionnaire\models\AnswerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Ответы на вопросы';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="answer-index">
<p>
<?= Html::a('Создать новый ответ', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= $this->render('_search_by_questionnaire', [
2021-11-25 12:33:08 +03:00
'modelSearch' => $searchModel,
]) ?>
2021-10-22 17:02:28 +03:00
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// [
// 'filter' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
// 'label' => 'Анкета',
// 'attribute' => 'questionnaire',
// 'value' => 'questionnaire.title'
// ],
2021-10-22 17:02:28 +03:00
[
2021-11-12 15:19:37 +03:00
'filter' => Question::find()->select(['question_body', 'id'])
->indexBy('id')->column(),
2021-10-22 17:02:28 +03:00
'attribute' => 'question_id',
2021-11-08 12:41:39 +03:00
'value' => 'question.question_body'
2021-10-22 17:02:28 +03:00
],
'answer_body',
[
'attribute' => 'answer_flag',
'format' => 'raw',
2021-11-08 12:41:39 +03:00
'filter' => AnswerHelper::answerFlagsList(),
2021-10-22 17:02:28 +03:00
'value' => function ($model) {
return AnswerHelper::answerFlagLabel($model->answer_flag);
2021-10-22 17:02:28 +03:00
},
],
[
'attribute' => 'status',
'format' => 'raw',
2021-11-08 12:41:39 +03:00
'filter' => StatusHelper::statusList(),
2021-10-29 17:06:09 +03:00
'value' => function($model){
2021-11-08 12:41:39 +03:00
return StatusHelper::statusLabel($model->status);
2021-10-29 17:06:09 +03:00
}
2021-10-22 17:02:28 +03:00
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>