cloudnc / ngx-sub-form

Utility library for breaking down an Angular form into multiple components
https://cloudnc.github.io/ngx-sub-form
MIT License
314 stars 33 forks source link

Polymorphic sub forms without form controls #302

Open avivs100 opened 1 year ago

avivs100 commented 1 year ago

Hi, I created a form with the help of your library and it is amazing and very clear. I ran into a small problem that you might be able to help me with because I couldn't find a solution. The problem is this: There is a form, one of whose controls is polymorphic. The user has to select a type of product from a dropdown and according to the type, an appropriate sub form should be opened. The sub forms that define form controls work fine, but the sub forms that do not define controls are not working properly (the purpose of such sub forms is only to build the appropriate dto for them by using toFormGroup and fromFormGroup). Apparently there is a problem with the return value of those subforms (with no controls) because no translation is performed because it actually returns Null. Are you familiar with the problem? Is there a solution you know about? Or maybe some workaround? Thank you very much

maxime1992 commented 1 year ago

Hello, polymorphism is well supported. You will be able to find plenty of examples looking in that folder (and you can compare the actual app visually if you'd like here).

If something isn't still working after that, please provide A MINIMAL repro on Stackblitz. And I insist on MINIMAL. Thanks!

avivs100 commented 10 months ago

Hi, I created A simple example of a form with sub form(with two polymorphic forms). 1 of them is without controls. In the code you can see my problem, if you will select Honda First the form will not be valid but if you choose first Toyota and then Honda it will work. the selection of the Honda need to be valid without choosing the Toyota first. App URL: https://stackblitz.com/edit/angular-ivy-nzakgy Thank you very much. @maxime1992