I have a long form with many inputs (some of them generated dinamically) and I would like to pass all these values at once to a function. How could I do it?
Thank you in advance.
I have a long form with many inputs (some of them generated dinamically) and I would like to pass all these values at once to a function. How could I do it?
Thank you in advance.
For long forms, I add all v-model variables to one object called form
and useform.email
on v-model. This allows me to get all the values at once when I submit the form.
<ion-item>
<ion-label>Email</ion-label>
<ion-input v-model="form.email"></ion-input>
</ion-item>
<ion-item>
<ion-label>Password</ion-label>
<ion-input v-model="form.password" type="password"></ion-input>
</ion-item>
data() {
return {
form: {
email: null
password: null
},
};
},
methods: {
submit() {
authStore.dispatch("login", this.form)
.then(() => {})
.catch(error => {});
}
}
Thank you, I think that will work.