1

I'm stuck on VueFormulate, specifically I'd like to populate an array from a <FormulateInput type="select" name="products"> component. That idea should be that every time you select an option that option should go into the products array of the model bound to <FormulateForm v-model="user"> but instead products just become a primitive integer instead of an array.

Let me show you some code from the SFC of the form itself

<template>
  <FormulateForm v-model="user" name="example" @submit="performSomething">

   <!-- Other fields working fine !-->

   <FormulateInput
        type="select"
        name="products"
        :label="$t('form.inputs.products.label')"
        :placeholder="$t('form.inputs.products.placeholder')"
        :options="products.map(p => ({ label: p.name, value: p.id }))"
      />

  </Formulateform>
</template>

props: {
   products: Array
}

// User model bound to Formulateform

data: () => ({
    user: {
      name: "",
      description: "",
      products: [], // This should be populated by the select box
    },
  }),

The expected behaviour should be that user.products gets filled with IDs from the select on every input, but instead it just replace the array with the ID of the first select. Of course I'm missing something but I don't get what, documentation does mention that every FormulateInput has an @input event but I'm not able to use it because the even itself is fired only once then I only get FormulateForm events

4

1 回答 1

1

原来是我的错,真是令人惊讶。有关解决方案的更多信息:https ://github.com/wearebraid/vue-formulate/issues/318

于 2020-11-18T15:18:24.427 回答