Script to empty several cells on modal close?

Hello,

Very rudimentary question here, but, is there a way to create a script to empty a load of text fields on my modal form, when the form closes.

I know I can add it on the event handler for close modal - however, rather than hard code each text component as separate handler - is there a way to run a short javascript or something, and then call that script?

Meaning if /when I update the fields in the form, I only need to update this script?

Or, even more clever - a script that can apply to any modal form? Although I know I'm pushing my luck here, especially given my very shallow coding expertise!

I've tried to use chatGPT to help me here, but I'm drawing blanks.... I think I just need to know the syntax to add to my script to make a textBox = ""

thanks!
Neil

You can clear the form on submit if need be or if not submitting by default and running another query you can use .clear
Screenshot 2023-08-03 at 1.51.29 PM

Thanks @ScottR - that explains it!
I was sure I had this working before and couldn't figure out what had happened.....

It's because I had actually got rid of the form for this modal, and just using text boxes - which is when this option disappears! Yet another reason why we should use a form where possible!

thanks,
Neil

1 Like

Hello, I read the document.
the form component has a setData method.

If all you text fields in the form is using default field name such as textInput1,textInput2, ect.
image

You can use js to rearrange that object, to set all property start with textInput to "", then set it back to form via `form1.setData(data)

Here is docs

2 Likes

@AnsonHwang - thank's a lot for this, very useful!

1 Like