Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How do I reset JSON Form widget inside the modal?

Issue

I was experimenting with JSON forms within a modal on Appsmith and noticed that the form data was not cleared when I closed the modal. To fix this, I learned that I need to use the resetWidget() function and manually clear the JSON form widget as a parameter.

Resolution

One of the users noticed that the JSON form inside a modal doesn't get cleared when the modal is closed. The solution to this problem is to use the resetWidget() function to reset the states of any widgets. To manually clear the JSON Form Widget, you need to use the resetWidget function as a parameter.

For example, to clear the JSONForm1 widget, you need to use the following code: {{resetWidget('JSONForm1')}}. This will reset the widget and clear any data that was entered into it so that it is empty the next time the modal is opened.

More information about using the resetWidget function can be found in the Appsmith documentation, which provides additional examples and explanations. By using this function, you can ensure that your users always start with a clean slate when they open a modal with a JSON form.