Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value of field when exactly two checkboxes are binded #3183

Closed
fatihmustafakurt opened this issue Feb 22, 2021 · 7 comments · Fixed by #2907
Closed

Wrong value of field when exactly two checkboxes are binded #3183

fatihmustafakurt opened this issue Feb 22, 2021 · 7 comments · Fixed by #2907
Labels
🐛 bug Unintended behavior 🛳 In PR This issue is being addressed in a PR

Comments

@fatihmustafakurt
Copy link

Versions

  • vee-validate: 4.1.19
  • vue: 3.0.5

Describe the bug
When there are exactly two checkbox fields binded to one form field, form field values are not correctly handled

To reproduce

Steps to reproduce the behavior:

  1. Go to codepen
  2. Click the submit
  3. you will see the alert which contains the value of field.
  4. Value of field contains something like
{
  "drink": [
    2,
    [
      2
    ]
  ]
}

Expected behavior
Value of field should be

{
  "drink": [
    2
  ]
}

Demo link
codepen

Additional context

@logaretm
Copy link
Owner

Doesn't seem to be happening to me, can you provide more information? what browser/OS do you use?

CleanShot.2021-02-22.at.23.56.11.mp4

@logaretm logaretm added the 🤔 needs reproduction This issue requires a demo label Feb 22, 2021
@fatihmustafakurt
Copy link
Author

fatihmustafakurt commented Feb 23, 2021

I am sorry, I had unintentionally changed the v-field's name attribute from 'drink' to 'drink[]'. Can you just try it with changing attribute from 'drink[]' to 'drink'?

Screen.Recording.2021-02-23.at.10.48.40.mov

@logaretm
Copy link
Owner

Thanks, will check it out later tonight

@logaretm logaretm added 🐛 bug Unintended behavior and removed 🤔 needs reproduction This issue requires a demo labels Feb 23, 2021
@logaretm
Copy link
Owner

thanks, the fix should be tagged in 4.1.20

@fatihmustafakurt
Copy link
Author

I am afraid, but another bug is introduced. To reproduce the bug,

  • Change the v-field's name attribute from 'drink[]' to 'drink'
  • Change the initial value from [2] to [3]
  • Click the submit button
  • Output will be
{
  "drink": [
    3,
    [
      3
    ]
  ]
}

@logaretm logaretm reopened this Feb 24, 2021
@logaretm
Copy link
Owner

Looks like it's fixed by the changes in #3176

@logaretm logaretm added the 🛳 In PR This issue is being addressed in a PR label Feb 24, 2021
@logaretm
Copy link
Owner

closed by #3176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior 🛳 In PR This issue is being addressed in a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants