/**
  * @inheritdoc
  */
 public function rules()
 {
     $rulesArray = [[['user_id', 'startdate'], 'required'], [['user_id', 'ticket_id'], 'integer'], [['cash', 'bonus_cash'], 'number', 'min' => 0, 'max' => 100000000], [['create_at', 'current_cost', 'residual'], 'safe'], [['residual'], 'safe', 'on' => 'pay-create'], [['residual'], 'integer', 'integerOnly' => true, 'min' => 0, 'on' => 'pay-edit'], [['comment'], 'string', 'max' => 255], ['user_id', 'exist', 'targetAttribute' => 'user_id', 'targetClass' => Profile::className()], ['ticket_id', 'exist', 'targetAttribute' => 'id', 'targetClass' => SeasonTicket::className()], ['ticket_id', 'notEmptyBoth'], ['groups', 'in', 'range' => array_keys(Group::getGroupArray()), 'allowArray' => true], ['startdate', 'date', 'format' => 'php:d.m.Y'], [['cash', 'bonus_cash'], 'default', 'value' => '0.00']];
     if ($this->maxBonusBalance) {
         $rulesArray[] = ['bonus_cash', 'number', 'min' => 0, 'max' => $this->maxBonusBalance, 'tooBig' => Module::t('pay-admin', 'Insufficient funds in the bonus account')];
     } else {
         $rulesArray[] = ['bonus_cash', 'validateBonusCash'];
     }
     return $rulesArray;
 }
<?php

use backend\modules\timetable\widgets\GroupGridView as GridView;
use backend\modules\group\models\Group;
echo GridView::widget(['id' => 'show-timetable', 'dataProvider' => $dataProvider, 'layout' => '{items}', 'tableOptions' => ['class' => 'table table-bordered text-center'], 'headerRowOptions' => ['class' => 'active'], 'mergeColumns' => ['week_day'], 'columns' => [['attribute' => 'week_day', 'options' => ['class' => 'col-xs-3'], 'contentOptions' => ['style' => 'vertical-align: middle;'], 'value' => function ($model) {
    return $model->weekArray[$model->week_day];
}], ['attribute' => 'start', 'options' => ['class' => 'col-xs-2'], 'contentOptions' => ['style' => 'vertical-align: middle;']], ['attribute' => 'end', 'options' => ['class' => 'col-xs-2'], 'contentOptions' => ['style' => 'vertical-align: middle;']], ['attribute' => 'group_id', 'options' => ['class' => 'col-xs-5'], 'value' => function ($model) {
    return Group::getGroupArray()[$model->group_id];
}]]]);
 /**
  * Creates a new Pay model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $user_id
  * @return mixed
  */
 public function actionCreate($user_id = false)
 {
     if ($user_id) {
         $profile = Profile::findOne(['user_id' => $user_id]);
         if (!$profile) {
             throw new HttpException(404);
         }
         $model = new Pay();
         $model->setScenario('pay-create');
         $model->maxBonusBalance = $profile->bonus_balance;
         $tickets = SeasonTicket::getTicketArray();
         //ajax validation
         if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             $groups = Group::getGroupArray();
             return $this->render('create', ['model' => $model, 'profile' => $profile, 'tickets' => $tickets, 'groups' => $groups]);
         }
     } else {
         $searchModel = new UserSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->get());
         return $this->render('listusers', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
     }
 }
                <?php 
echo Html::a('<i class="fa fa-eye"></i>', ['view'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'View')]);
?>
                <?php 
echo Html::a('<i class="fa fa-leanpub"></i>', ['publish'], ['class' => 'btn btn-warning btn-sm', 'title' => Module::t('timetable-admin', 'Publish')]);
?>
                <?php 
echo Html::a('<i class="fa fa-plus"></i>', ['create'], ['class' => 'btn btn-primary btn-sm', 'title' => Module::t('timetable-admin', 'Create')]);
?>
                <?php 
echo Html::a('<i class="fa fa-ban"></i>', ['cancel-lessons'], ['class' => 'btn btn-danger btn-sm', 'title' => Module::t('timetable-admin', 'Cancel lessons')]);
?>
                <?php 
echo Html::a('<i class="fa fa-trash"></i>', ['batch-delete'], ['class' => 'btn btn-danger btn-sm', 'id' => 'batch-delete', 'title' => Module::t('timetable-admin', 'Delete selected')]);
?>
            </div>
        </div>
        <div class="box-body">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'id' => $gridId, 'filterModel' => $searchModel, 'export' => false, 'columns' => [['class' => CheckboxColumn::classname()], ['attribute' => 'week_day', 'pageSummary' => true, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'dropDownList', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form'], 'data' => Timetable::getWeekArray()], 'value' => function ($model) {
    return $model->weekArray[$model->week_day];
}, 'filter' => Html::activeDropDownList($searchModel, 'week_day', Timetable::getWeekArray(), ['class' => 'form-control', 'prompt' => ''])], ['attribute' => 'start', 'filter' => false, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'textInput', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']]], ['attribute' => 'end', 'filter' => false, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'textInput', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']]], ['attribute' => 'group_id', 'class' => 'kartik\\grid\\EditableColumn', 'format' => 'html', 'editableOptions' => ['inputType' => 'dropDownList', 'data' => Group::getGroupArray(), 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']], 'value' => function ($model) {
    return Group::getGroupArray()[$model->group_id];
}, 'filter' => Html::activeDropDownList($searchModel, 'group_id', Group::getGroupArray(), ['class' => 'form-control', 'prompt' => ''])], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['clone' => function ($url) {
    return Html::a('<i class="fa fa-files-o"></i>', $url, ['title' => Module::t('timetable-admin', 'Clone row'), 'class' => 'btn btn-default btn-xs']);
}], 'template' => '{clone} {update} {delete}', 'buttonOptions' => ['class' => 'btn btn-default btn-xs'], 'headerOptions' => ['style' => 'width:100px;'], 'header' => Module::t('timetable-admin', 'Actions')]]]);
?>
        </div>
    </div>
</div>
 /**
  * Updates an existing Timetable model.
  * If update is successful, the browser will be redirected to the 'view' page
  * @return mixed
  */
 public function actionEdit()
 {
     if (Yii::$app->request->post('hasEditable') && Yii::$app->request->post('editableKey')) {
         $model = $this->findModel(Yii::$app->request->post('editableKey'));
         $model->setScenario('timetable-edit');
         $postEditableIndex = Yii::$app->request->post('editableIndex');
         $postTimetable = Yii::$app->request->post('Timetable')[$postEditableIndex];
         $output = '';
         $message = '';
         if (is_array($postTimetable)) {
             foreach ($postTimetable as $key => $value) {
                 if (isset($model->{$key})) {
                     $model->{$key} = $output = $value;
                     if ('week_day' === (string) $key) {
                         $output = Timetable::getWeekArray()[$value];
                     }
                     if ('group_id' === (string) $key) {
                         $output = Group::getGroupArray()[$value];
                     }
                     if (!$model->validate() || !$model->save(false)) {
                         echo Json::encode(['output' => $output, 'message' => $model->errors[$key]]);
                     } else {
                         echo Json::encode(['output' => $output, 'message' => '']);
                     }
                     break;
                 }
             }
         }
     }
 }