In my current ZF2 project I have a complex Form with multiple levels of nested Fieldsets, that reflect the structure of objects to be saved in the background. Currently the data is sent directly to the Controller and gets saved to the database, if it's valid.
Now an intermediate step should be implemented: The user should get a chance to check the input data before it's saved to the database. If he decides, that it's correct, the form data should be submitted and saved to the database; if the user decides, that the form has to be edited, he should be able to go back to the form and correct it. (Of course all that in a loop, until the user is happy with the form and submit it.)
That means, a preview page is needed. This page/action should get the data and display it somehow (as a table or however). The data needs to be stored somewhere temporarily and be ready to be "hydrated" to the Form object and saved. If the user wants to update the form, the form should be restored.
How can I implement this requirement?
UPDATE
I'm looking for a server-side solution. The preview should be a new page and not a JavScript/client-side generated HTML on the same page (for the tracking and other purposes).
I would say that the best solution would be to implement a client sided (java-)script that is executed before your perform the form
POSTrequest. You could catch the form submit event and render a client side view in which you show the current state of all the form fields (name and value). If the user clicksacceptyou continue thePOSToperation. If the user clicks cancel you return to the view of the form where you allow additional changes and the whole thing repeats itself.It should not be difficult to find examples on how to do this...
One example is this blog post, but there are many more to find with the help of Google.