Category: UI Widgets
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.

Text Input not resetting on Form submit

Issue

I am having an issue with a disabled text input widget on my form that is bound to {{utils.getUniqueID()}}. The purpose of this widget is to serve as the primary key for the database row, but when the form is submitted, the ID widget text does not change and a new unique ID is not generated. I have tried resetting the form widget with children on submit success, but it still doesn't work. However, it was resolved by storing the random number in a store variable and binding it to the Id input widget.

Resolution

The issue was that a text input widget on a form, bound to a unique ID generator function, was not resetting when the form was submitted. The solution was to store the random number generated by the function in a store variable using the "storeValue" function, and bind the input widget's Default Value to the store variable using double curly brackets.

Here's an example of how to modify the getUniqueID function and the input widget binding:

In the getUniqueID function:
storeValue('randomId',Math.floor(Date.now() * Math.random()).toString(32));

In the input widget binding:
Default Value: {{appsmith.store.randomId}}

Additionally, ensure that the random number generator function is called every time the Save button is clicked, to ensure a new number is generated when the form is reset.