I am a beginner when it comes to using Angular and I am currently dealing with a form that consists of the following fields.
this.catform = new FormGroup({
name: new FormControl('', Validators.required,),
source: new FormControl('', Validators.required),
event: new FormControl('', Validators.required),
cond: this.fb.array([this.Cond()], Validators.required)
});
Cond() : FormGroup {
return this.fb.group({
disp : new FormControl(1),
field: new FormControl('', Validators.required),
ct: new FormControl('', Validators.required),
value: new FormControl('', Validators.required),
ot : 'AND'
});
}
Whenever I submit the form and use this.catform.reset(), the "disp" and "ot" fields reset to null, causing the entire form to have null values. This leads to unsuccessful form submission because the backend does not accept null values for these fields. Since these two fields are not present in the HTML template, I am unable to edit them from there. I am looking for suggestions on how to maintain these values as specified above even after form reset.