You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the vue-query library for backend communication. After a successful request, I want to reset the form values. However, there is currently no way to access the reset function outside of the Form component because the $form variable (declared as v-scoper="$form") exists only within the Form component scope.
Upon reviewing the source code, I found a useForm function, similar to the one in vee-validate. However, since PrimeVue automatically registers all fields and defineField behaves differently, I cannot define $form outside the component using this function.
Example code:
<scriptsetuplang="ts">constformValues=ref({email: "",});const{ isPending, mutate }=useMutation({mutationFn: (email: string)=>apiRequest(email),onSuccess: ()=>{// TODO: how to reset form values? }});constonSubmit=async({ valid, values }: FormSubmitEvent)=>{if(!valid||isPending.value)return;mutate(values.email);};</script><template><Formv-slot="$form"
:initial-values="formValues"
@submit="onSubmit"
><divclass="flex flex-col gap-1"><FloatLabel><InputTextname="email"type="text"fluid/><labelfor="email">Email</label></FloatLabel></div></Form></template>
Describe the bug
I am using the
vue-query
library for backend communication. After a successful request, I want to reset the form values. However, there is currently no way to access the reset function outside of theForm
component because the $form variable (declared asv-scoper="$form"
) exists only within the Form component scope.Upon reviewing the source code, I found a
useForm
function, similar to the one invee-validate
. However, sincePrimeVue
automatically registers all fields anddefineField
behaves differently, I cannot define$form
outside the component using this function.Example code:
Reproducer
https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-prtoxz
PrimeVue version
4.2.1
Vue version
3.x
Language
ALL
Build / Runtime
Nuxt
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response
The text was updated successfully, but these errors were encountered: