The docs show how to add buttons but they do nothing. Can someone show how a form is cleared?
Hi @RichardVencu,
I’m not sure I have the full context on what you are trying to achieve here, but have you added an onSubmit
handler to the form?
These docs have an example, have you seen this?
https://developer.atlassian.com/platform/forge/ui-kit-components/form/
Let me know how you get on
Hi. Yes as I replicated the documentation I can submit. However after submitting the form is not getting clear automatically. I need to add code to clear fields values. This is necessary in order to allow the form to be submitted more than once like for customized loging work for instance
Hello everyone. I deal with the same problem - clearing form values after submitting. Has anyone come up with solutions yet?
Hi, from my experiments I got some hack to do that. I noticed from the Admin Panel I created that I can have multiple forms in multiple fragments and I can show one fragment or another based on rules (such as click on a button or another condition that triggers new rendering). Then I noticed when I return to the normal form, the fields are empty. Did not test but my idea is to duplicate the fragment containing the form (duplicate the logic if needed to have unique names) and alternate between states form1-form2 after each submission.
If you try and it works please let me know as well so I can save testing time
Hi @AndrazHostnik,
We’re aware of this problem and are currently exploring a few ways to solve it. We hope to have an update for you in the next quarter
Any update on this situation?
I have also run into this issue trying to create a dynamic form. I can see no way to reset the form values.
I also still can’t find any option to reset a form
For example have a look at the documentation of embedding a form into a modal:
Modify it a little to log the current form values
const { handleSubmit, getFieldId, register, getValues } = useForm();
console.log(`Current form values ${JSON.stringify(getValues())}`);
- Open the modal and provide a name for the “user” property
- Close and re-open the modal
The user input field is rendered empty (because no default value provided), but the internal form state actually still holds the previously entered name (seen from the logs)
There is definetly missing a reset/clear function to be called on closing!