Skip to content

How to use useFieldArray with normal <input and v-model /> #3617

Answered by logaretm
thamibn asked this question in Q&A
Discussion options

You must be logged in to vote

You can try rendering the input element with Field component:

<Field as="el-input" clearable size="small" :name="`deliveries[${idx}].branch`" type="text" />

Or create a custom useField component that uses the el-input element. The official vee-validate examples for element plus have a few ways you can integrate vee-validate with it.


Or If you handle it manually, you will have to break up the v-model directive. I didn't try this out personally but it should work:

// in setup
const { fields, update, insert } = useFieldArray('deliveries');

function handleInputChange(idx, value) {
  if (!fields.value[idx]) {
    insert(idx, { branch: value });
    return;
  }

   update(idx, value);
}
<el-…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by thamibn
Comment options

You must be logged in to vote
4 replies
@logaretm
Comment options

@eMeRiKa13
Comment options

@logaretm
Comment options

@eMeRiKa13
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants