/** * Creates a new View model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new View(); for ($i = 1; $i <= Lang::find()->count(); $i++) { $model_content[$i] = new ViewLang(); $model_content[$i]['lang_id'] = $i; $model_content[$i]['id'] = 0; } if (Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) { foreach ($model_content as $key => $content) { $content->id = $model->id; $content->lang_id = $key; $content->save(false); } return $this->redirect(['/view']); } else { return $this->render('create', ['model' => $model, 'model_content' => $model_content]); } }