1
votes

Since I updated from Angular 2.0.0 to 2.4.4 today, my model driven form isn't working anymore.

this.creationForm = this.fb.group({
    ...
    SomeProp: [[], [<any>Validators.required]]
});

SomeProp should be valid when at least one value is in the array. When debugging I saw that there are some values in the array. Somehow it's still invalid.

I'm not sure if I missed any breaking changes.

Update January 23th

I downgraded to [email protected]. The issue isn't existing anymore. So the "fix" mentioned in the changelog broke it for me. I will check with the next update and get active if it isn't fixed then.

Why the typecast <any>? Never saw this before! - Fals
See the changelog here: github.com/angular/angular/blob/2.4.x/… "forms: Validators.required properly validate arrays (#13362) (17c5fa9), closes #12274". Validators.required did not work with arrays previous to this change. Now it should work as expected. You seem to be having the opposite effect though so maybe the issue is somewhere else. - dmungin
@Fals It was from a tutorial, still doesn't work though. Am I using the wrong "syntax"? - sandrooco
Alternate syntax: SomeProp: this.fb.array([], Validators.required) just in case you want to try it. - silentsod
That doesn't work either. @silentsod What else could I try? - sandrooco