I have seen a few StackOverflow issues with this question, but none of them seem to have proven answers that work.
I am building a dynamically created Reactive Form Using Angular. StackBlitz here . The user has the option to add "groups" and "conditions" within the groups. Each group can be further nested using FormArrays.
The form works as expected. Here are the main pieces of the form:
- AppComponent: The main Parent Component
- GroupControlComponent: The child of the parent. Takes care of all the group objects
- ConditionFormComponent: The child of the GroupControlComponent. Takes care of all the conditions within the groups
This is what a basic object looks like:
{
// appcomponent level
"statement": {
//groupcontrol level
"groups": [
{
// conditionform level
"conjunctor": null,
"conditions": [
{
"variable": null
}
],
"groups": []
}
]
}
}
When I set up validation, I want everything to be required. So I went through the FormBuilder, on the parent and children components, and set Validators.required
to true on all form controls.
this._fb.control({
conjunctor: null,
conditions: [[], Validators.required],
groups: [[], Validators.required]
})
(this is the case on all controls)
The problem is, the form now always is valid. Even when the form is not actually valid. Is it possible to check form validity while using nested child components?
Here is some more information about this specific form, if required:
Cannot Find Control with Path Using ngIf on Recursive Angular Form
Angular Deeply Nested Reactive Form: Cannot find control with path on nested FormArray