public function actionEdit($id = null)
    {
        if ($id === null) {
            $model = new Context;
            $dataProvider = null;
        } else {
            $model = $this->findModel($id);
            $dataProvider = new ActiveDataProvider(
                [
                    'query' => Language::find()->where(['context_id' => $model->id]),
                ]
            );
        }
        $isLoaded = $model->load(Yii::$app->request->post());
        $hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-context'))
            || (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-context'));
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->redirect(['edit', 'id' => $model->id]);
        } else {
            return $this->render(
                'edit',
                [
                    'dataProvider' => $dataProvider,
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }