Thank you, Sean, for your response. It made me revisit the implementation and come up with a fresh approach.
My initial (and preferred) solution was to use a query parameter that I could append to the redirect URL. In legacy Kentico versions, this was easy thanks to macros. In XbyK, however, there doesn’t seem to be such a flexible way to set up a dynamic value for the query parameter in the Form widget properties. You actually suggested something similar in your reply, and I’d be keen to learn how you would do it. Specifically, where is the right place to safely inject such a query parameter?
Thanks also for pointing me to the window.kentico.updateableFormHelper.submitForm
method. I don’t think patching or manipulating it is a good idea for maintenance reasons, but reading through its implementation gave me more insight into how form submission and redirects are handled. I noticed that the action
attribute of the form
tag contains a URL with a query parameter holding the redirect URL. I tried manipulating that to inject an additional query parameter, but the form submission failed when I did so, most likely due to security concerns, which makes sense.
You asked about HTTP request interception on the client side. I did experiment with this using a separate “observer” that tracked requests and checked whether they matched the FormSubmit URLs, without relying on the window.kentico.updateableFormHelper.submitForm
method.
Finally, I gave the cookies approach another try, as you mentioned. I had tested it before, but something wasn’t working quite right. Since I had changed the overall implementation quite a bit, I decided to revisit it, and this time it worked. In the end, I was able to simplify the process, move most of the logic to the server side, and eliminate a few unnecessary steps.
Here’s the current flow:
Form submission → Event handler → Create GUID and store it in both the form submission and a cookie → Redirect → Summary widget reads the cookie, fetches the form submission server-side, and renders the data. I added a couple of extra security measures, but that’s the core flow.
So, I was able to simplify things. This could make a good blog post topic since it’s not an unusual scenario. I also think there’s an opportunity for the product to provide better support for this kind of use case.