Is there a way to include the associatedAccount as both key and value in the formgroup, so that it is submitted along with the rest of the form data? Any suggestions would be greatly appreciated. Thank you.
Currently, I am planning to add the modelForm value to the post request using this.accountService.create(this.modelForm.value), but I also need to incorporate the value from the getAssociatedAccount request. Thank you for your help.
The associatedAccount value is not part of the Form itself, but I aim to include it in the formgroup as a single object.
Perhaps something like: associatedAccount: this.associatedAccount
#request
getAssociatedAccount() {
this.isInProgress = true;
this.userService.getUserProfile(this.authService.authUser.nameid)
.pipe(
finalize(() => this.isInProgress = false),
).subscribe({
next: (res:any) => {
if (res.isSuccess) {
this.associatedAccount = res.data.associatedAccount
}
},
error: err => noop,
complete: () => noop
});
}
#model
private _createModelForm(): FormGroup {
return this.formBuilder.group({
// id: [this.model.id || 0],
emailAddress: new FormControl(this.model.emailAddress, [
Validators.required,
]),
firstName: this.model.firstName,
roleId: this.model.roleId,
lastName: this.model.lastName,
phoneNumber: this.model.phoneNumber,
companyName: this.model.companyName,
ssocredentials: this.model.ssocredentials,
accountId: this.accountId,
title: this.model.title,
isSso: [this.model.isSso || []],
});
}