formBuilder.group([{counties: [{id: 1, name: "name"}]) converts array to first object

0 Answers 25 Views
Forms MultiSelect
John
Top achievements
Rank 1
Iron
John asked on 21 Dec 2023, 03:00 PM

Using formBuilder to create a reactive form when I noticed that it turns array properties in to the first object in the array. This is breaking my multiselect drop down as it is expecting an array.

I create a stack blitz demonstration. 

https://stackblitz.com/edit/angular-bnet6z?file=src%2Fapp%2Fapp.component.ts

This is based off of you https://www.telerik.com/kendo-angular-ui/components/dropdowns/multiselect/forms/#toc-reactive-forms demonstration where I changed the form building to use the form builder.

Multiselect then reports these errors.

  • ERROR
    1. Error: values.reduce is not a function
    2. ERROR
      1. Error: Expected values of array type. See https://www.telerik.com/kendo-angular-ui/components/dropdowns/multiselect/value-binding
      2. The workaround is to build the form manually, but it really feels like a bug in formBuilder. Is there something else that will work to prevent formBuilder from reducing arrays?

      3. No answers yet. Maybe you can help?

        Tags
        Forms MultiSelect
        Asked by
        John
        Top achievements
        Rank 1
        Iron
        Share this question
        or