/** * Creates a new Area model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionUpdate($id) { $base = $this->findModel($id); $type = $base->type; list($title, $model, $view) = AreaHelp::getBlockHook($type); $model = \Yii::createObject(array_merge(ArrayHelper::toArray($base), ["class" => $model])); $model->setIsNewRecord(false); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $this->flash('success', Yii::t('hass', 'updated success')); } else { $this->flash('error', Yii::t('hass', 'updated error. {0}', $model->formatErrors())); } return $this->refresh(); } return $this->render('update', ["items" => AreaHelp::getBlockNav($type), "title" => $title, "view" => $view, "model" => $model]); }