/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new User(); $profile = new Profile(); $post = Yii::$app->request->post(); if ($model->load($post) && $profile->load($post)) { $model->loadDefaultValues(true); $validation = $this->performAjaxValidation([$model, $profile]); if ($validation !== false) { return $validation; } $model->activkey = Yii::$app->security->generateRandomString(); $profile->user_id = 0; if ($model->validate()) { $model->password = Module::getInstance()->encrypting($model->password); if ($model->save()) { $profile->user_id = $model->id; $profile->loadDefaultValues(true); if ($profile->save(true)) { Yii::$app->user->setFlash('success', Module::t("User has been created successfully.")); return $this->redirect(['view', 'id' => $model->id]); } } } } return $this->render('create', ['model' => $model, 'profile' => $profile]); }