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

Form reset does not work #7195

Open
1 of 4 tasks
jereeves5 opened this issue Feb 5, 2025 · 1 comment
Open
1 of 4 tasks

Form reset does not work #7195

jereeves5 opened this issue Feb 5, 2025 · 1 comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Milestone

Comments

@jereeves5
Copy link

Describe the bug

The ability to reset a form appears to be broken. It doesn't actually change the values back. I've tried directly referring to "$form.reset()" and using "form.reset()" with a "ref='form'" Please refer to this discussion:
https://stackoverflow.com/questions/79413343/primevue-how-to-use-reset-emit-to-clear-form/79413351

Example here:
https://stackblitz.com/edit/u9znrf-ivrsnctn

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

No response

Reproducer

https://stackblitz.com/edit/u9znrf-ivrsnctn

Environment

Uses Primevue and Privevue Forms v4.2.5.

Vue version

^3.2.45

PrimeVue version

4.2.5

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

Please visit the example:
https://stackblitz.com/edit/u9znrf-ivrsnctn

Type something in the input boxes. Hit the reset links. It will change the value in the form state data displayed above the inputs, but the actual input values won't change.

Expected behavior

This should be resetting the actual form input values.

@jereeves5 jereeves5 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 5, 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 6, 2025
@tugcekucukoglu tugcekucukoglu added this to the 4.3.1 milestone Feb 6, 2025
@github-project-automation github-project-automation bot moved this to Review in PrimeVue Feb 6, 2025
@jraez
Copy link

jraez commented Feb 11, 2025

I have the same issue. I use a workaround to make it works, hoping 4.3.1 will solve it.

On the Form component, I use a key, and when I want to reset the form, I update the key. It will force Vue to re-render the form with initial values.

import { ref } from "vue";
const formId = ref<string>(String(new Date().getTime()));
const onSave = (event: FormSubmitEvent) => {
  if (event.valid) {
    // your logic here
    formId.value = String(new Date().getTime());
  }
};
  <Form @submit="onSave" :key="formId">Form</Form>

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

3 participants