autoResetForm property in the useModalForm hook not resetting all fields as expected. Here are some key points and potential solutions based on the provided knowledge sources:autoResetForm property is designed to reset the form after a successful submit and is true by default.autoResetForm does not work correctly in some scenarios. For example, when changing the title to trigger .resetFields() inside the autoResetForm condition, the old value might appear momentarily before updating to the new value..resetFields() isn't sufficient to clear the form in useFormModal of the antd package.reset() before closing the modal. This ensures that the form is reset to its default values when the modal is closed.initialValues are set correctly in useModalForm().formProps to avoid issues with stale data.useDrawerForm, similar issues and solutions apply as discussed in the GitHub issue (https://github.com/refinedev/refine/issues/756).autoResetForm property not resetting all fields, here are some key points and potential solutions based on the provided knowledge sources:autoResetForm property is designed to reset the form after a successful submit and is true by default.autoResetForm does not work correctly in some scenarios. For example, when changing the title to trigger .resetFields() inside the autoResetForm condition, the old value might appear momentarily before updating to the new value..resetFields() isn't sufficient to clear the form in useFormModal of the antd package. Although this is specific to Ant Design, similar issues might occur with MUI.reset() before closing the modal. This ensures that the form is reset to its default values when the modal is closed.initialValues are set correctly in useModalForm().formProps to avoid issues with stale data.useDrawerForm, similar issues and solutions apply as discussed in the GitHub issue (https://github.com/refinedev/refine/issues/756).autoResetForm property is designed to reset the form after a successful submit and is true by default.reset() before closing the modal. This ensures that the form is reset to its default values when the modal is closed.initialValues are set correctly in useModalForm().formProps to avoid issues with stale data.useDrawerForm, similar issues and solutions apply as discussed in the GitHub issue (https://github.com/refinedev/refine/issues/756).autoResetForm property is not resetting all fields as expected, you can manually call the reset method to ensure all fields are reset. Here is how you can do it:reset method from the form instance to reset all fields. This can be done, for example, when the modal is closed.reset in a useModalForm setup:``
3. **Additional Considerations**:
- Ensure that the initialValues are set correctly in useModalForm().formProps to avoid issues with stale data.
- If you are using useDrawerForm, similar issues and solutions apply as discussed in the **GitHub issue** (<https://github.com/refinedev/refine/issues/756>).
By manually calling the reset` method, you can ensure that all fields are reset to their default values when the modal is closed or after form submission.onFinish directly was working for you instead of using modal.submit, you can continue to use that approach. Hereβs how you can structure your code to manually handle form submission and reset the form fields:onFinish function directly and then manually reset the form fields.``
3. **Additional Considerations**:
- Ensure that the initialValues are set correctly in useModalForm().formProps to avoid issues with stale data.
- If you are using useDrawerForm, similar issues and solutions apply as discussed in the **GitHub issue** (<https://github.com/refinedev/refine/issues/756>).
By manually handling the form submission and calling the reset` method, you can ensure that all fields are reset to their default values when the modal is closed or after form submission.autoResetFormautoResetFormautoResetFormautoResetFormautoResetFormautoResetFormautoResetFormautoResetFormautoResetFormautoResetFormuseModalFormuseModalForm.resetFields().resetFields().resetFields().resetFields()useFormModaluseFormModalreset()reset()reset()initialValuesinitialValuesinitialValuesuseModalForm().formPropsuseModalForm().formPropsuseModalForm().formPropsuseDrawerFormuseDrawerFormuseDrawerForm``
3. **Additional Considerations**:
- Ensure that the ``
3. **Additional Considerations**:
- Ensure that the are set correctly in are set correctly in to avoid issues with stale data.
- If you are using to avoid issues with stale data.
- If you are using , similar issues and solutions apply as discussed in the **GitHub issue** (<https://github.com/refinedev/refine/issues/756>).
By manually calling the onFinishonFinishmodal.submit, similar issues and solutions apply as discussed in the **GitHub issue** (<https://github.com/refinedev/refine/issues/756>).
By manually handling the form submission and calling the useModalForm({
refineCoreProps: { action: 'create' },
defaultValues,
modalProps: {
autoResetFormWhenClose: true // <-- something like this
},
resolver: valibotResolver(schema)
});useModalForm({
refineCoreProps: { action: 'create' },
defaultValues,
modalProps: {
autoResetFormWhenClose: true // <-- something like this
},
resolver: valibotResolver(schema)
});useModalForm({
refineCoreProps: { action: 'create' },
defaultValues,
modalProps: {
autoResetFormWhenClose: true // <-- something like this
},
resolver: valibotResolver(schema)
});const modalForm = useModalForm({
modalProps: {
autoResetForm: false,
},
});const modalForm = useModalForm({
modalProps: {
autoResetForm: false,
},
});