controller, 'newModel', ] ); $languages = Language::getActive(); if ($this->hasAlias) { /** * @var \artbox\core\models\Alias[] $aliases */ $aliases = $model->loadAliases(); } $post = \Yii::$app->request->post(); if (!empty($this->languageFields)) { Model::loadMultiple($model->getVariationModels(), $post); } if ($model->load($post) && $model->save()) { if ($this->hasAlias) { /** * @var \artbox\core\models\Alias[] $aliases */ Model::loadMultiple($aliases, $post); foreach ($aliases as $alias) { $alias->route = $model->getRoute(); if ($this->overwriteEntity === null) { $alias->entity = $model::className(); } else { $alias->entity = $this->overwriteEntity; } $alias->save(); /** * @var \yii\db\ActiveRecord $modelLang */ $modelLang = $model->getVariationModel($alias->language_id); $modelLang->alias_id = $alias->id; $modelLang->save(); } } if ($this->hasGallery) { $model->saveImages($post); } return $this->controller->redirect([ 'index' ]); } return $this->controller->render( $this->viewPath, [ 'action' => $this, 'model' => $model, 'languages' => $languages, ] ); } }