Vee-validate: validate dynamically created forms

Created on 12 Sep 2019  ยท  2Comments  ยท  Source: logaretm/vee-validate

Versions

  • vee-validate: 3.0.4
  • vue: 2.6.10

Describe the bug
I use a ValidationObserver to observe several dynamically build forms. Basically I have an email form and have a button to dynamically add more emails. After the user has added some emails and clicks on submit I want the validation validates all created form components but it only does the last one!

Code Example

<ValidationObserver ref="observer" v-slot="{invalid}" tag="form">
    <BuefyForm v-for="email in emails" :key="email.id" :email.sync="email"/>
</ValidationObserver>

Expected behavior
The observer should validate all given forms before submit!

Demo link
https://codesandbox.io/s/veevalidate-components-buefy-dn82h

Desktop:

  • OS: macOS Mojave (10.14.6)
  • Browser: Chrome
  • Version 76
โ” question

Most helpful comment

All your providers have the same name, which when provided without an explict vid will be used as the provider's id. That means that the last provider will overwrite the previous ones.

You should add a vid prop to your component with a unique id for each item so it can be used as the id instead of the name prop.

here is an example:

https://codesandbox.io/s/veevalidate-components-buefy-r6bfu

All 2 comments

All your providers have the same name, which when provided without an explict vid will be used as the provider's id. That means that the last provider will overwrite the previous ones.

You should add a vid prop to your component with a unique id for each item so it can be used as the id instead of the name prop.

here is an example:

https://codesandbox.io/s/veevalidate-components-buefy-r6bfu

ok but what if I have more than one input?

Edit: Found it out already...
https://codesandbox.io/s/veevalidate-components-buefy-tj2h1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hoagiex picture Hoagiex  ยท  3Comments

Youdaman picture Youdaman  ยท  3Comments

MeltedFreddo picture MeltedFreddo  ยท  3Comments

jagasan picture jagasan  ยท  3Comments

Shchepotin picture Shchepotin  ยท  3Comments