Reputation: 7138
I have a form which is showing multiple input based on database data and I need to get each input value when I submit my form.
<form ref="form" :model="form">
<div class="row">
<div
class="col-md-6"
v-for="(field, index) in fields"
:key="index"
>
<input
class="form-control"
v-model="form.field"
:placeholder="field.title"
/>
</div>
</div>
<vs-button
class="mt-3"
@click="onSubmit"
native-type="submit"
gradient
>
Generate
</vs-button>
</form>
data() {
return {
fields: [],
form: {
field: [],
},
};
},
My issue is that currently when I fill 1 input others get the same value, I need to fill each input individually.
Any idea?
Upvotes: 1
Views: 1967
Reputation: 343
You're using your v-model
pointing to form.field
, try to use v-model="form.field[index]"
Upvotes: 2