What is the best way to do this - multiple forms on the same page updating the same record?

Hi I have a simple issue which I am sure is only difficult because of my knowledge gap!

Looking for some advice on best method of doing the following:

Background:

I have a node content page with multiple forms on it, set up to be completed one after the other. When form-1 server connect is successful it form-1 is hidden and form-2 is shown and on success form-2 is also hidden and form-3 is shown. Each of the forms adds additional (new) data to different fields in record, not updating the same data. Every form once successfully submitted saves data to the same table row record - there are reasons for the use of multiple forms in this way, rather than one form which I wont go into here.

I can go back and forward through the forms to edit the data.

The problem:

  • When Form-1 is successfully submitted it creates a new record ID and that ID is added into a global Session variable.

  • When the user completes Form-2 I use the session variable ID created in From-1 as a condition for the update query action so the update query knows which record to add the data to.

There are a few problems using session variable to store the record ID. If the user refreshes the page it appears the Session ID is lost and there is no way the forms knows which record is being updated.

I am sure that on from 1 creation of the record and ID I should be doing something more stable!

My question:

What is the best way to do the above, do I use a session ID or do I do something with that record ID to do something more persistent??

As a side note: I also want the ability for the user to be able to come back to theses forms at anytime to edit them.

Any suggestions on the best method to be able to achieve the above would be welcome?? Pointing me in the right direction?

Many thanks!

Followup: I think I have figured this out and it looks like Global session variables are persistent on refresh of the browser page.

Is this the case?

Have you tried using the one form where different parts of the form are hidden as required. The submit button can be normal button that triggers the next part of the form. The last button can be the submit button.

This would be a more efficient way because there would be just the one interaction with the backend.

hi @ben

Thank you.

I did think about that, but what I need it to do is on each step save the data to the table, so if it is incomplete they user can come back and finish it later. Is there a way of doing this with a typical multi step without saving or updating the whole form each time?

Cheers!

If you want to keep track of the inputs even when the user leaves the page (or website) containing the inputs.

Have a look at
https://docsdev.wappler.io/guides/creating-a-shopping-cart-with-the-data-store-component

Thanks @ben

This is interesting I might be able to do something with this!