I am currently in the process of developing a form that enables users to configure their payment preferences. The form includes a dropdown menu where users can select their preferred payment method.
For each payment method, there is a FormGroup
that contains specific options for that selected method:
form: FormGroup = new FormGroup({
method: new FormControl('paypal', {
validators: [
Validators.required,
],
}),
paypal: new FormGroup({
email: new FormControl(null, {
validators: [
Validators.required,
Validators.pattern(EMAIL_PATTERN)
],
}),
}),
other: new FormGroup({
email: new FormControl(null, {
validators: [
Validators.required,
Validators.pattern(EMAIL_PATTERN)
],
}),
}),
});
An issue I am encountering is that the form is only deemed valid if both FormGroups
are considered valid.
However, it is my intention for the form to be deemed valid as soon as the FormGroup
for the selected payment method is valid.