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

Resolved value is incorrect for groups of multiple checkboxes in PrimeVue Forms #7169

Open
1 of 4 tasks
PotatoesMaster opened this issue Jan 30, 2025 · 0 comments
Open
1 of 4 tasks
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Milestone

Comments

@PotatoesMaster
Copy link

Describe the bug

Using PrimeVue Forms, when a group of checkboxes is present, the form state does not include all the values but only the state for the last changed checkbox.

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

I think I located the problem: in packages/forms/src/useform/index.js. The state is overwritten with the last checkbox changed.

I don't know how to fix that: I think the state should be an array when several checkboxes with the same name are present in the form, but I am unsure of how to check for this condition and prevent issues with single checkboxes.

Reproducer

https://stackblitz.com/edit/primevue-forms-checkbox-group-issue?file=src%2FApp.vue

Environment

Vue version

3.5.13

PrimeVue version

4.2.5

Node version

20.18.0

Browser(s)

No response

Steps to reproduce the behavior

  1. In a PrimeVue Form, include several checkboxes having the same value for the "name" attribute and different values for the "value" attribute.
  2. Change field value or submit the form.
  3. The resolved field value is an array containing the value of the lastly checked checkbox, or it is empty if the last action was to uncheck a checkbox.

Expected behavior

I expect the resolved value to be an array containing the values of all the checked checkboxes, or to be empty if none are selected.

@PotatoesMaster PotatoesMaster added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 30, 2025
@tugcekucukoglu tugcekucukoglu added Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Feb 5, 2025
@tugcekucukoglu tugcekucukoglu added this to the 4.3.1 milestone Feb 5, 2025
@github-project-automation github-project-automation bot moved this to Review in PrimeVue Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
Status: Review
Development

No branches or pull requests

2 participants