I have a form that includes the ability for the user to upload a file. Upon submit, I run a couple of validation checks in the beforeSave event. I am able to detect the error and return false and thereby halt the save to my collection from happening. Unfortunately, the upload button has already uploaded the file. Since the upload file is connected to an image field in the collection, the error did not allow the new record (along with the image) to be added to the collection, but the file was still uploaded as an orphan.
How do I keep this from happening? I have inferred from some other discussions that I may have to manually control the upload buttons instead of linking the button to a collection via the provided wix editor, but that seems unfortunate.
Any insight is appreciated.