/** * Updates an existing Role model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (\Yii::$app->request->isAjax) { \Yii::$app->response->format = Response::FORMAT_JSON; $model->load(\Yii::$app->request->post()); return ActiveForm::validate($model); } if ($model->load(\Yii::$app->request->post()) && $model->save()) { \Yii::$app->session->setFlash(\yz\Yz::FLASH_SUCCESS, \Yii::t('admin/t', 'Record was successfully updated')); return $this->getCreateUpdateResponse($model); } else { return $this->render('update', ['model' => $model]); } }