-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
@primevue/forms: Form
components submit event parameter missing values
#7006
Comments
I noticed it only contains the values object if you either set the initial values parameter or if you edit the input manually. |
They somehow changed the entire behavior of the Forms library in one of the last minor versions. |
Hi, @undefinedhuman. Thank you! |
Sorry, my bad the
|
First of all, I would like to thank everyone for their work; it is a wonderful library. I would like to reopen this issue because, in the API section of the documentation, it still mentions that the FormSubmitEvent includes an object called values. This is very confusing. |
The PR not merged yet @mertsincan |
A temporary workaround I discovered is to pass the resolver to the Form. The resolver passed to the Form should always define all the fields, even if they are optional. If a field is omitted from the resolver, it will not be included in the submitted values (e.values). For example, using a resolver like this: const resolver = zodResolver(
z.object({
username: z.string().optional(),
password: z.string().optional(),
}),
); ensures that both username and password are present in e.values. However, if the password field is not defined in the resolver, it doesn't appear in the values object. |
Describe the bug
Prehistory
Documentation states that:
Also it states that:
primevue/packages/forms/src/form/Form.d.ts
Lines 83 to 108 in e5af2d3
primevue/packages/forms/src/useform/index.js
Lines 91 to 103 in e5af2d3
Actual issue:
An object returned by submit callback DOES NOT have
values
field.Reproducer
https://stackblitz.com/edit/primevue-nuxt-issue-template-qsshy1rm?file=app.vue
PrimeVue version
4.2.5
Vue version
3.x
Language
TypeScript
Build / Runtime
Nuxt
Browser(s)
Chrome 131
Steps to reproduce the behavior
submit
callback does not containvalues
Expected behavior
Existence of
values
in an object returned bysubmit
callback.The text was updated successfully, but these errors were encountered: