/** * Creates a new UserDetails model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserDetails(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * * @todo find how how to get the next inserted ID, reserve it, and save both User and UserDetails at the same time. * @return [type] [description] */ public function actionSignup() { $signupform = new SignupForm(); $userDetails = new UserDetails(); $data = Yii::$app->request->post(); if ($signupform->load($data)) { if ($user = $signupform->signup()) { // get the users ID fron the users TBO && add it to the users details TBO obj $data['UserDetails']['user_id'] = $user->getAttribute('id'); $userDetails->load($data); if ($userDetails->save()) { if (Yii::$app->getUser()->login($user)) { return \Yii::$app->response->redirect(['site/signup-complete']); } } } } return $this->render('signup', ['model' => $signupform, 'details' => $userDetails]); }