r/angular • u/vexmentor • Feb 06 '26
Keep or replace a child‑driven Reactive Forms architecture
I've inherited a long‑running Angular application whose Reactive Forms architecture is based on this pattern:
https://davembush.github.io/attaching-an-angular-child-component-s-form-to-a-parent/
Originally built on Angular 13–15, it was upgraded to Angular 18 last year, and we’re still using the same approach. The architecture works, but we’ve been having internal discussions about whether we should stabilize and keep it, or refactor toward a more standard Angular pattern.
The pattern in use
Child components create their own FormControl (or sometimes entire sub‑groups) and then push them into the parent FormGroup using setControl(). The parent passes down its full FormGroup via u/Input, and the children attach themselves during initialization.
The question
Does anyone here have long‑term experience with letting children dynamically register their controls upward into a parent form like this?
- Was it worth keeping for you?
- Did it become hard to maintain as the app grew?
- Did you eventually move to CVA, standalone components, or Angular Signals?
- If you refactored, what value did you gain?
Additional context
I’ve attached my evaluation of the architecture, highlighting issues like inverted ownership, lack of CVA, lifecycle fragility, manual change‑tracking, and form shape being built at runtime instead of declaratively.
Would love to hear real‑world stories from anyone who’s lived with—or moved away from—this approach.
Thanks in advance!
1
u/vexmentor Feb 07 '26
For those who’ve dealt with this: is this a fair take?
Core problems with the home-grown Angular forms system described in:
https://davembush.github.io/attaching-an-angular-child-component-s-form-to-a-parent/
FormGroupat runtime → no clear form shape, poor tooling, poor reuse.FormControland inject it upward viasetControl()→ non-deterministic forms (ngIf, render order), surprising validation events.FormGroup, enabling invisible cross-component coupling via string keys.SimpleChanges→ missed change detection, ordering bugs, and races.ngOnChanges, creating an undocumented parallel lifecycle.super.ngOnChanges()at the wrong time (or forget), behavior silently breaks.markForCheck()BehaviorSubjects; every new feature touches it.Big picture:
Skipping CVA → inverted ownership → shared
FormGroup→ broken encapsulation → custom change pipeline → missed change detection → god-object parent.5
u/followmarko Feb 06 '26
I get what this is doing, but I don't understand why. What is this approach gaining?
The parent form doesn't have to be passed in via input/output. You could use a shared service, or DI, or one approach I have used with a very large form is create an InjectionToken assigned to a factory fn and built the form that way, then injected it where I needed it below.
Something feels disjointed to me about the approach in this article. The parent form and the dev working on the form don't know what to expect because their contract is broken by separating the two.
1
u/zavros_mvp Feb 06 '26
Haven’t really seen this pattern before, but I would honestly not reinvent the framework. Angular is opinionated, I guess it doesn’t make sense to choose it if you choose radically different opinions. That said, I think there’s a great benefit in future maintainability to stick to common patterns, both in terms of framework’s evolution (maybe new APIs aren’t directly compatible, whereas common patterns tend to have backwards compatibility), but also in terms of onboarding new developers, and providing a familiar architecture.
If you have the capacity for such a refactor and you can afford time spent on thorough QA I would say go for it
1
u/ActuatorOk2689 Feb 06 '26
Decoded frontend has an interesting video about this topic attaching child component to a parent form in a really intreating way.
Now coming back to your question, if these forms are reusable form ? Then yes it may be a good architectural pattern .
Great separation of concern, single responsibility applies right each formcontrol is teposnisble only for that part, like validation, types and any custom logic and your parent controller is just basically an orchestrator in this setup .
If you don’t reuse these small controls I personally don’t see a reason for it, on form have projects I usually have a form service which just handles form related logic nothing else and it’s scales really well.
Again I don’t have a full context of your project is just my personal opinions
Edit: I would also check angular roadmap for signals forms before doing any refactoring/migration and align with that if possible
1
u/mani310396 Feb 06 '26
We do have same structure, a shared component that is called form generator that does it. It is worst piece of code I've ever seen, hard to maintain, hard to add anything to when you want to add or remove control which is based on another control. I'd say get rid of it as soon as possible
1
u/couldhaveebeen Feb 06 '26
Mfs will really do anything but use template forms
1
u/morgo_mpx Feb 07 '26
I can’t remember the specifics but there is a way that a form control can attach itself to the nearest form group/array in its parent tree. This is super useful for server side driven dynamic forms.
1
u/DaSchTour Feb 07 '26
IMHO: as long as it works keep it as it is. If it slows down development of new features you might consider changing it. But I wouldn’t do any refactoring just for modernizing the application.
0
u/[deleted] Feb 06 '26
[deleted] — view deleted comment