-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested ArrayModel #414
Comments
@stekontar Hi! I'd never thought someone would ever goes this far :-) Could you provide your form model? My first guess is that it actually should work... |
Hi @udos86 I deal with huge forms (almost 100 fields) and I must say that your library saved me a lot of time. kendo-example.model.ts
I was glad but soon the next step unfortunately did not worked
kendo-example.component.html
kendo-example.component.ts
I also tried to use the formService in order to add it dynamically (that's the main goal) but did not worked either Thank you very much. |
I had to comment on this, 100+ fields? Are you launching a missile bro? Haha |
From a usability point of view I'd not recommend nesting such an enormous amount of controls in one form. However, I made some quick tests with nested form arrays and I could not verify any unexpected behavior here. What do you exactly mean by "did not go as expected" and "the next step unfortunately did not worked"? |
@udos86, I reckon @stekontar meant the Add-Remove buttons didnt work and he made various attempts but they weren't working? I've had the same problem using the input data mentioned above. Any suggestions? |
@bappy004 indeed. the problem is on add/remove buttons. specifically the control is undefined as the angular function this.formGroup.get(context.id) only works for the first level. As first approach I m trying to set a "parentGroup"/"parentArray" in DynamicFormGroupModel/DynamicFormArrayModel property (with current index if it is array) in order to know each control's "path" that's what I have figure out until now. I don't know if it is in the right way, still looking. |
@udos86 "What do you exactly mean by "did not go as expected" and "the next step unfortunately did not worked"?" About "did not go as expected" I was referencing to DynamicFormGroupModel but please ignore it, it was my mistake. Thank you. |
@stekontar Now I see, thanks! Let me think about it. I'll try to provide a solution. |
The problem is when there are FormArrays nested in FormArrays. Heres my suggestion from the duplicate ticket. Since the every So you can simply do something like this:
|
Thanks for your suggestion but a component should never be referenced by a model. I figured out a solution to this (see 63ac803). From |
How do you envision calculating the entire |
Then just traverse up by using the new |
Is there no way to just make the corresponding control available in the |
No, because when applying a template to a form array
Most developers will never face a use case of several levels of form arrays. At least as long as they're not suffering of overly complex form UI designs.
I'll also add a getter |
@udos86 using the following insert snippet, seems that path is not updated correctly. am I missing something?
Regards, |
This is, what you would like to do:
|
Thank's for your answer. Regards, |
Thanks, the new solution is great. |
The solution is very nice but I thing that there is a bug. Regards, |
Yes, I gave this a try and found an issue as well. Basically all is well if the path is Perhaps we should open a new issue? |
@kuwas |
The current solution only works for directly nested form arrays. Otherwise I would have to introduce a Thanks for reporting the bug. I'll try to deliver a fix as soon as possible! |
There'll be a new approach in Now whenever a form group is created via You can now retrieve a full form control path by calling |
Great! Thanks for the fix. |
@udos86 @udos86 I believe that problem would be solved if in dynamic-form.service.ts replace the function insertFormArrayGroup
to this
now I can call the function from bootstrap-example.component.ts with this.
currently I test it with 3 level deep arrays (the model at the top) and is working correctly. Regards, |
@stekontar Thanks for your tests. I actually thought this problem would be ultimately solved by the current implementation but I have to check it again. By the way: You don't need to call Please also note that you can now directly reference a |
@stekontar I can confirm that your line of code is the missing piece to make it all work finally. Thanks! |
I am trying to create nested arrayModel like the following example
https://plnkr.co/edit/vSODkb8i7o54X3fST9VF?p=preview
but it seems that currently is not supported (or I am doing something wrong)
I already check issue #225 and #289 (and I wrote another comment there) but I cannot figure out how to do it.
Suggestion: in dynamic-form.service.ts in method findById I add the following snippet in order to get the nested model
currently I face a problem in order to get from FormGroup the nested FormArray based on context.id
Ideally I would like support of n-th level of modelArray
Thank you.
Regards,
S.
The text was updated successfully, but these errors were encountered: