/** * Creates a new RssSources model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new RssSources(); $postData = Yii::$app->request->post(); if ($model->load($postData) && $model->save()) { if (isset($postData['RssSources']['settings'])) { foreach ($postData['RssSources']['settings'] as $name => $value) { $sourcesSettings = new SourcesSettings(); $sourcesSettings->source_id = $model->source_id; $sourcesSettings->name = $name; $sourcesSettings->value = $value; $sourcesSettings->save(); } } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }