How to block a form field from resetting upon submit?


Novice here. I'm building a very basic form with the app interface and I would like for the Your Name field (a selection list) to not reset to default after the form has been submitted.

The way I'm attempting to do this now is by writing to a local storage variable called yourNameReload and using this as the initial value of the field. It doesn't work and instead I see an error message in the Debug list.

Only on initial loading of the form do I expect the Your Name field to be empty. Subsequent loads should keep the value that was previously selected.

Am I trying to do this the hard way? Is there a way to prevent this field from resetting at the form level?

Thank you.

Event handler to set the local variable

Debug error

Hi @cparker4486

Retool doesn't inherently store data between app reloads, so local storage seems like the best solution for this use case. In other words, Retool isn't configured to recall information about previously selected form data. Another option would be writing the form data to an api or database and populating the form with that resource. Does it work if you make the following changes:

  1. change the default value to localStorage.values.yourNameReload:

  2. Add quotes around yourNameReload in the event hander:

  3. Add .value after self in the event handler: