markAllAsTouched() not propegated to subforms
See original GitHub issueRepro:
- One root form A with sub form B
- Submit button on root form can always be clicked
- Submit calls
markAllAsTouched()
- Submit calls
Expected:
- all fields on the entire form tree incl sub-forms should be touched
Actual:
- only controls directly on the root form are being marked as touched
Note:
- I assume it does not work as the sub-form is only connected to the root form via value accessor
- and looking at the value accessor interface,
touched
is not an event that gets propagated from parent to child (only the other way around registerOnTouched)
The intent of this issue is to try and come up with a best practice to handle this and if possible to extend the library to assist in these cases.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:20 (6 by maintainers)
Top Results From Across the Web
Both markAllAsTouched and markAsTouched don't affect ...
And the events triggered on the form group would propagate through the sub forms. Example code. parent.component.ts this.form = this.
Read more >Best Way To Use markAllAsTouched in Angular Forms
First, we target forms that have the formGroup directive. Next, we obtain a reference to the FormGroupDirective instance via dependency ...
Read more >Angular: Nested Reactive Forms Using ... - Medium
In this post, we will see how to implement nested reactive forms using composite control value accessors(CVAs). Kara Erickson of the Angular Core...
Read more >Angular Custom Form Controls - Complete Guide
Build a fully functional custom form control, compatible with template-driven and reactive forms, as well as with all built-in and custom ...
Read more >Quick Tip for Angular Forms: Keep your markAllAsTouched DRY
And in each submit handler you've called markAllAsTouched() to cover cases where users didn't touch one of the fields: We can automate this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can we all please give a 👍 to the following issue: https://github.com/angular/angular/issues/27315 ?
If that was solved upstream we could implement this feature really easily ❤️
Hi everyone, today I was dealing with this problem and trying to use your ideas as inspiration I created the following gist that let me workaround the markAsTouched/markAllAsTouched problem.
NgxSubForm markAllAsTouched fix
All of your feedback is very preciated and I hope this could help someone of you.