quickest-silver
quickest-silver•12mo ago

useModalForm seems to be invalidating all data that's present on the site, is there any way around?

I'm using useModalForm to create a nested entity (say I am in the edit form of a Post and I want to create a new Category and attach the category to the Post I was editing). Everything works fine until I try to save and attach the received category.ID to my Post. As soon as I save the Category, the complete Post-Form gets reloaded. I think this might be intentional to get "the latest data", but is there a way to avoid reloading ALL of the data? In this case my Post might have lots of changes and Refine is just reloading and overwriting all fields with the "fresh" data.
3 Replies
kapa.ai
kapa.ai•12mo ago
Hi @bastianwegge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the extracts, it seems like the behavior you're experiencing might be related to the autoResetForm property of the useModalForm hook. By default, this property is set to true, which means the form will be reset after a successful submit. If you want to prevent the form from resetting after submitting, you can set autoResetForm to false when you call useModalForm. Here's an example:
const modalForm = useModalForm({
modalProps: {
autoResetForm: false,
},
});
const modalForm = useModalForm({
modalProps: {
autoResetForm: false,
},
});
However, the extracts don't provide information specifically about updating a nested entity and preventing a reload of all data. For more detailed guidance, you might want to refer to the Refine documentation (https://refine.dev/docs) or seek help from the Refine community. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai•12mo ago
<@317433576721219584> kapa.ai is still learning and improving, please let us know how it did by reacting below
quickest-silver
quickest-silver•12mo ago
Nope that doesn't help. It's the other form that gets reloaded, which I'd like to avoid. @core maybe you have some suggestion for me? 🙂 I was actually using syncWithLocation: true, within useModalForm which caused the reload. Another one on my end 😄 ✅