None of the solutions here worked for me (Angular 14), so I ended up having to duplicate FormControls for the required fields. Then, in the valueChanges subscription that populates those disabled fields, I also populate the hidden fields.
this.addressFormGroup = this._fb.group({
address1: new FormControl({ value: null, disabled: true }, Validators.required),
address2: new FormControl({ value: null, disabled: true }),
city: new FormControl({ value: null, disabled: true, }, Validators.required),
country: new FormControl({ value: null, disabled: true }),
county: new FormControl({value: null, disabled: true}),
state: new FormControl({ value: null, disabled: true }, Validators.required),
zip: new FormControl({ value: null, disabled: true }, Validators.required),
// hidden, required fields
address1Hidden: new FormControl(null, Validators.required),
cityHidden: new FormControl(null, Validators.required),
stateHidden: new FormControl(null, Validators.required),
zipHidden: new FormControl(null, Validators.required)
});
Copying the values from the disabled fields into the hidden fields.
someEvent.subscribe((response) => {
(<FormControl>this.addressFormGroup.controls['address1']).setValue(response.addressLine1);
(<FormControl>this.addressFormGroup.controls['address2']).setValue(response.addressLine1);
(<FormControl>this.addressFormGroup.controls['country']).setValue(response.country);
(<FormControl>this.addressFormGroup.controls['county']).setValue(response.county);
(<FormControl>this.addressFormGroup.controls['city']).setValue(response.city);
(<FormControl>this.addressFormGroup.controls['state']).setValue(response.state);
(<FormControl>this.addressFormGroup.controls['zip']).setValue(response.zip);
(<FormControl>this.addressFormGroup.controls['address1Hidden']).setValue(response.addressLine1);
(<FormControl>this.addressFormGroup.controls['cityHidden']).setValue(response.city);
(<FormControl>this.addressFormGroup.controls['stateHidden']).setValue(response.state);
(<FormControl>this.addressFormGroup.controls['zipHidden']).setValue(response.zip);
}
Technically, the Validators added in the first snippet are superfluous.