Is this the intended behaviour?
I have a form that I want to use for creating new records or editing existing records.
New record creation is fine, the form resets after submit.
I'm using setData to "load" existing data into the form for the user to modify. When you submit the form the data is updated but the form retains the edited record data. I can't then reset or empty the form back to defaults.
Steps to repro:
Create a form with a text field
Check the "reset on successful submit" option on the form
Create a button that runs form.setData() and gives a value to the text field
Check the value of form.initialData, should be ""
Enter some data in the text field and submit, form resets the text field back to ""
Click the button to run setData - text field should have the value you defined
Check the value of initialData, it'll now be set to what you used in setData
Click submit or call form.reset() and you will still have the setData value
What should I be using to "load" a form if it's not setData? thanks.
Hey there Appreciate you writing in and pointing this out! I wrote up a bug report for this and tied it to this thread so I can update you right when progress is made In the meantime, would you be able to use setValue() on the specific components in the form?
Just came across this problem too, was rather confused there for a bit so glad it's already been reported.
+1
Just so you know the use case. I was populating a form based on a table row click and then allowing the user to edit the fields.
On submission of that form, I need to update the database but the ID of the record I'm updating is not an available field as it's not tied to any visible fields in the form.
Using form.initialData just seemed a tidy way of referencing that original ID.
Typically that would work but in this form I have a JSON object that needs updating hence the need to use form.setData which then overwrites the initialData property.