formly-js / vue-formly

JavaScript powered forms for Vue.js
MIT License
237 stars 33 forks source link

Dynamic forms in formly angualr based on array length #53

Closed ACJamesX closed 7 months ago

ACJamesX commented 7 months ago

Hi need help in creating dynamic forms based on my cards array length below is my template code where i have added the formly tag. <div fxFlex="30" *ngFor="let card of cards; let cardIndex = index" class="card">

{{ card.product.name }}

What is happening here is that same form is being used in my all cards which creates issue for eg when i select the dropdown in one card it gets opened in the other card too. I feel this is because a single form is repeated in all my cards , so need help to fix this. PS: I am using Angular material THANKS IN ADVANCE

ACJamesX commented 7 months ago

@juristr @aitboudad

matt-sanders commented 7 months ago

Hey there

This repo is unmaintained at the moment and it's been years since I've looked at it, so I'm speaking from memory here, but a couple of things jumped out at me.

Firstly, you mentioned you're using angular material but this is the library for Vue Formly. Are you definitely using Vue Formly or Angular Formly?

If you have the same form for multiple cards, you should probably try and separate that, so that you're using different instances of the same form. Alternatively, give your fields a unique name based on the card, probably by issuing some sort of ID.

This was made for Vue 2, so if none of the above work, maybe it's a Vue 2 vs 3 issue.

See how you get on with those, hopefully something there works for you!

ACJamesX commented 7 months ago

Hi @matt-sanders im using Angular Formly

matt-sanders commented 7 months ago

Ah ok, try your luck over at that repo