Would be nice to have a “form reset on submission” in addition to the “clear on submission” option currently available.
As an example, I have a form in a modal, where the default value for one of the fields is the number 0. I have it set so that the form is cleared after submission. However, once the form is cleared, the default value of the field above is not set to 0, but is instead blank.
I have the same need. I have some default values which I would like to be reset after the form has been submitted as opposed to cleared.
In my case some of those fields are always disabled as a way to give the user visibility into the values, but they shouldn't be allowed to change them.
Also needing this. Any updates from the Retool team? This almost makes the default values useless. Seems like it wouldn't be a huge effort to implement compared to the ROI (way better UX).
Hey! Thanks everyone for bringing this to our attention. We have submitted a report for this, and will update this post when we have any further updates!
Hi all,
Late to the party here, but a quick fix I've used is using a setData argument, where each of the form's data keys are set to null. To make it super easy
create a transformer with the following general code
let x = {{FORMNAME.data}};
let k = _.keys(x);
for (i=0; i < k.length ; i++){
x[k[i]]=null;
}
return x;
Use an event-handler > control component > set data > transformer.value
I have a button with an X on it on every form that calls this kind of event handler, allowing reset to defaults.
The on submission behavior is also a bit more flexible now, defaulting to reseting if there is a default value, or clearing if there is no default value: