{"action":"reopened","issue":{"url":"https://api.github.com/repos/trntv/yii2-starter-kit/issues/178","labels_url":"https://api.github.com/repos/trntv/yii2-starter-kit/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/trntv/yii2-starter-kit/issues/178/comments","events_url":"https://api.github.com/repos/trntv/yii2-starter-kit/issues/178/events","html_url":"https://github.com/trntv/yii2-starter-kit/issues/178","id":80823573,"number":178,"title":"How to save user and userprofile model in single form.","user":{"login":"mohdbashir","id":3686692,"avatar_url":"https://avatars.githubusercontent.com/u/3686692?v=3","gravatar_id":"","url":"https://api.github.com/users/mohdbashir","html_url":"https://github.com/mohdbashir","followers_url":"https://api.github.com/users/mohdbashir/followers","following_url":"https://api.github.com/users/mohdbashir/following{/other_user}","gists_url":"https://api.github.com/users/mohdbashir/gists{/gist_id}","starred_url":"https://api.github.com/users/mohdbashir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohdbashir/subscriptions","organizations_url":"https://api.github.com/users/mohdbashir/orgs","repos_url":"https://api.github.com/users/mohdbashir/repos","events_url":"https://api.github.com/users/mohdbashir/events{/privacy}","received_events_url":"https://api.github.com/users/mohdbashir/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-26T06:44:53Z","updated_at":"2015-05-26T08:12:14Z","closed_at":null,"body":"I would like to save or create user with userprofile on single form. With the below code form is showing and validation is also working but userprofile data not saved. can you please help where i am doing mistake?\r\n\r\nUserController.php\r\n\r\n\r\n     public function actionCreate()\r\n    {\r\n        $model = new UserForm();\r\n        $profileModel = new UserProfile();\r\n        \r\n        $model->setScenario('create');\r\n        if ($model->load(Yii::$app->request->post()) && $model->save()) {\r\n\r\n            if ($profileModel->load(Yii::$app->request->post()) && $profileModel->save()) \r\n              return $this->redirect(['index']);\r\n        }\r\n\r\n        return $this->render('create', [\r\n            'model' => $model,\r\n            'profileModel' => $profileModel,\r\n            'roles' => ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name')\r\n        ]);\r\n    }\r\n\r\n\r\n_form.php\r\n\r\n    <?php $form = ActiveForm::begin(); ?>\r\n        <?= $form->field($profileModel, 'firstname') ?>\r\n        <?= $form->field($profileModel, 'middlename') ?>\r\n        <?= $form->field($profileModel, 'lastname') ?>\r\n        <?= $form->field($profileModel, 'mobile') ?>\r\n        <?= $form->field($profileModel, 'gender')->dropDownlist([\r\n            \\backend\\models\\UserForm::GENDER_FEMALE => Yii::t('frontend', 'Female'),\r\n            \\backend\\models\\UserForm::GENDER_MALE => Yii::t('frontend', 'Male')\r\n        ]) ?>  \r\n        <?= $form->field($model, 'username') ?>\r\n        <?= $form->field($model, 'email') ?>\r\n        <?= $form->field($model, 'password')->passwordInput() ?>\r\n        <?= $form->field($model, 'status')->label(Yii::t('backend', 'Active'))->checkbox() ?>\r\n        <?= $form->field($model, 'roles')->checkboxList($roles) ?>\r\n        <div class=\"form-group\">\r\n            <?= Html::submitButton(Yii::t('backend', 'Save'), ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?>\r\n        </div>\r\n    <?php ActiveForm::end(); ?>\r\n\r\n"}}