/** * Update model page. * * @param integer $id Post ID * * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $model->setScenario('admin-update'); $statusArray = PageModel::statusLabels(); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { if ($model->save(false)) { return $this->refresh(); } else { Yii::$app->session->setFlash('danger', Module::t('comments-models', 'BACKEND_FLASH_FAIL_ADMIN_UPDATE')); return $this->refresh(); } } elseif (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } } return $this->render('update', ['model' => $model, 'statusArray' => $statusArray]); }