RensTillmann / super-forms

18 stars 14 forks source link

Unique Code Generation happening on the client side #28

Closed saeedkola closed 4 years ago

saeedkola commented 4 years ago

Unique code generation is happening on the client side, not server side upon form submission. As a result there are duplicates being created, if the user is submitting multiple form entries. In my case I have used redirect on submit option to display a custom confirmation message, when the user clicks back button browser to submit another entry, the unique code in the hidden field is not changing and duplicates are being created.

RensTillmann commented 4 years ago

Thanks for the info, however code generation is not done client side (of course not, that would be rather stupid). But regarding the "Return/Back" button from the browser it might indeed be that the browser is "populating" that specific field with the same "unique" code that was generated beforehand.

We will investigate this issue and try to apply a fix for this scenario. Thanks.

RensTillmann commented 4 years ago

Hi, could you please attach the form export here for testing purposes? We just tested the issue on our end but it's not happening for us. Also let us know in which browser you done your test.

saeedkola commented 4 years ago

super-form-export.zip Initially even I thought it was happening because of browser autocomplete. But then I set autocomplete="off" in includes/class-shortcodes.php $result .= '<form autocomplete="off" enctype="multipart/form-data"'; That stopped the form elements from auto populating but the value in the hidden field was still showing the previously generated random code.

saeedkola commented 4 years ago

image In the screenshot above you can see that uniqueid2 field value has been set even before submitting the form. In an ideal scenario, IMO, this code should be generated after the form has been submitted.

RensTillmann commented 4 years ago

Done some more testing on this issue, and was able to reproduce it in Firefox since you are also using that browser. We will make sure to implement a fix for this. The reason that the code is generated before the form is submitted is because this way you can already do things in the form with that generated code. It has it's use cases. Anyway we will make sure that the code will "regenerate" when the "Back" button in the browser was clicked. That way this duplicate issue shouldn't be happening again.

RensTillmann commented 4 years ago

This issue is now solved in v4.9.454. You can update to that version to solve this problem.