1

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.

Code

<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: [],
      },
    };
},

Issue

My issue is that currently when I fill 1 input others get the same value, I need to fill each input individually.

Screenshots

one

two

Any idea?

1
  • have you tried field[index]? Commented Dec 11, 2020 at 12:13

1 Answer 1

2

You're using your v-model pointing to form.field, try to use v-model="form.field[index]"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.