/** * Creates a new PageData model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new PageData(); $page = new Page(); $model->setScenario('create'); if (Yii::$app->request->isPost) { $page->load(Yii::$app->request->post()); $model->load(Yii::$app->request->post()); if ($page->validate()) { $model->id_page = $page->id; if ($page->save() && $model->save()) { return $this->redirect(['index']); } } } return $this->render('create', ['page' => $page, 'model' => $model]); }