Skip to content

Fields of the same name but different type get messed up #461

@orientalperil

Description

@orientalperil

Environment

Vite 4.4.5
Vueform 1.9.6
Vue 3.3.4
npm

Reproduction

https://stackblitz.com/edit/github-bwjmhwik-2l1jekvb

Describe the bug

I have a form that dynamically adds questions based on given answers. The first question field has the name "0". Some answers to that question will add a new question with the name "0_0". Sometimes the type of "0_0" will be a string and sometimes an array. When the type changes Vueform makes a mistake and puts the wrong value in or just completely removes the field.

Choose Friend then John. "0_0" will be a string
Choose Family then Brother, Sister. "0_0" will be an array of 2 items

Repro the bug:

  1. Choose Friend then John. Then choose Family then Brother. "0_0" will be a bool type when it should be an array.
  2. Choose Other. Choose Family then Brother. "0_0" is absent from the form data
  3. Choose Family then Brother. Choose Other. "0_0" is an array type with "Brother" inside but the textinput has "Brother". "0_0" should be a string
  4. Choose Other. Choose Friend. "0_0" is absent from the form data

These scenarios demonstrate some strange unexpected behavior. It looks like when the field type changes vueform is not detecting the right thing to do and tries to apply the value regardless of type.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions