form values revert to old values just after submit is pressed
@kapa.ai using antd editDrawerForm, the new values get passed to the mutation and everything works, but just after submitting the form input values revert to their original values. How can I keep this from happening?
5 Replies
Hi @amvdxc. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It sounds like you are experiencing an issue where the form values revert to their original values after submission when using
editDrawerForm
in Ant Design. This behavior might be related to the form resetting itself after submission.
To address this issue, you can try the following steps:
1. Disable Auto Reset: Ensure that the autoResetForm
property is set to false
. By default, autoResetForm
is true
, which resets the form after a successful submit. You can disable this by setting it to false
.
2. Check formProps.onFinish
: Make sure you are using formProps.onFinish
to handle the form submission. This method handles the closing of the drawer and clearing the fields under the hood, which might be causing the reset behavior.
Here is an example of how you can set up your editDrawerForm
:
By ensuring autoResetForm
is set to false
and using formProps.onFinish
, you should be able to prevent the form from resetting to its original values after submission.
For more details, you can refer to the documentation on autoResetForm
(https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form/#autoresetform) and formProps (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form/#formprops).
If the issue persists, please provide more details or check if there are any other custom behaviors in your form that might be causing the reset.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@705425032960016475> kapa.ai is still learning and improving, please let us know how it did by reacting below
equal-aquaOP•5mo ago
@kapa.ai perfect thx
Let me check the knowledge base for you. One moment! :books:
----------------------
It sounds like you are experiencing an issue where the form values revert to their original values after submission when using
editDrawerForm
in Ant Design. This behavior might be related to the form resetting itself after submission.
To address this issue, you can try the following steps:
1. Disable Auto Reset: Ensure that the autoResetForm
property is set to false
. By default, autoResetForm
is true
, which resets the form after a successful submit. You can disable this by setting it to false
.
2. Check formProps.onFinish
: Make sure you are using formProps.onFinish
to handle the form submission. This method handles the closing of the drawer and clearing the fields under the hood, which might be causing the reset behavior.
Here is an example of how you can set up your editDrawerForm
:
By ensuring autoResetForm
is set to false
and using formProps.onFinish
, you should be able to prevent the form from resetting to its original values after submission.
For more details, you can refer to the documentation on autoResetForm
(https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form/#autoresetform) and formProps (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form/#formprops).
If the issue persists, please provide more details or check if there are any other custom behaviors in your form that might be causing the reset.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@705425032960016475> kapa.ai is still learning and improving, please let us know how it did by reacting below