I am currently working on a form that consists of 4-5 different types of controls. In response to specific user actions, I need to determine if any of the controls contain a value at any point in the form's lifecycle, whether it is pristine or dirty. My approach cannot rely solely on the form states for this determination. Unfortunately, looping through the controls is not feasible due to 'this.myForm.controls' not being an array type. Additionally, despite having no values present, 'this.myForm.value' always returns an object.
Below is the code used to create the form:
this.searchForm = this.fb.group({
'ids': this.fb.control([], multipleInputValidator(2)),
'locationName': this.fb.control([], Validators.minLength(2)),
'accountCodes': this.fb.control([], multipleInputValidator(2)),
'regionCodes': this.fb.control([], multipleInputValidator(2)),
'city': this.fb.control([], Validators.minLength(2)),
'typeIds': this.fb.control([]),
'centreIds': this.fb.control([]),
'siteCodes': this.fb.control([]),
'statusCode': this.fb.control([]),
'from': this.fb.control([]),
'to': this.fb.control([])
});