/**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $user = new User(['scenario' => 'create']);
     $profile = new Profile();
     if ($user->load(Yii::$app->request->post()) && $profile->load(Yii::$app->request->post())) {
         if ($user->validate() && $profile->validate()) {
             //$user->populateRelation('profile', $profile);
             if ($user->save(false)) {
                 $user->link('profile', $profile);
                 Yii::$app->session->setFlash('success', Module::t('users', 'User has been successfully created.'));
                 return $this->redirect(['update', 'id' => $user->id]);
             } else {
                 Yii::$app->session->setFlash('danger', Module::t('users', 'User has not been saved. Please try again!'));
                 return $this->refresh();
             }
         }
     }
     return $this->render('create', ['user' => $user, 'profile' => $profile]);
 }