Skip to content
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

Explain why empty form arrays are not included in this.formGroupValues #174

Closed
jaycetde opened this issue May 27, 2020 · 3 comments · Fixed by #188
Closed

Explain why empty form arrays are not included in this.formGroupValues #174

jaycetde opened this issue May 27, 2020 · 3 comments · Fixed by #188
Assignees
Labels
released on @feat-rewrite state: has PR A PR is available for that issue type: bug/fix This is a bug or at least needs a fix

Comments

@jaycetde
Copy link

if (values.length > 0 && values.some(x => !isNullOrUndefined(x))) {

It's not difficult to work around, but could someone please provide some insight as to why an empty FormArray is not included in this.formGroupValues? I would expect it to return an empty array. Now, wherever need to work with these items, I have to write it like this: (this.formGroupValues.myArray || []).filter(...)

If there's a good reason for it, I would like to know what it is.

This package is awesome. Thank you

@maxime1992
Copy link
Contributor

Hi @jaycetde it sounds like this was intended to manage the formGroupErrors and impacted the formGroupValues.

We've been working on a complete rewrite and did decide not to reuse that pattern which is overly complicated and not easy to read (+error prone apparently 😅).

Hopefully it's solve there, I'll check later on 👍 (and keep that one opened in the meantime)

@maxime1992 maxime1992 added state: has PR A PR is available for that issue type: bug/fix This is a bug or at least needs a fix labels Jul 10, 2020
@maxime1992 maxime1992 self-assigned this Jul 10, 2020
@maxime1992
Copy link
Contributor

☝️ I marked as has PR and assigned myself so that no else take this one because I think the rewrite will solve it.

@maxime1992
Copy link
Contributor

Hey @jaycetde 👋 just to let you know, I had a quick look to see if this would be solved in the new version and it is ✔️. In the new version, formGroupValues is gone and you'd simply access the values like this: form.formGroup.value :)

It's only published as a pre-release for now and the doc is not yet updated but if you want to give it a go you can have a look on the new branch here: https://github.com/cloudnc/ngx-sub-form/tree/feat-rewrite/src/app/main-rewrite where all the forms are using the new approach 😸 Not too hard to understand if you're already familiar with ngx-sub-form 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @feat-rewrite state: has PR A PR is available for that issue type: bug/fix This is a bug or at least needs a fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants