How to implement a form preview page in Zend Framework 2?

In my current ZF2 project, I have a complex Form with several levels of nested Fieldset s that reflect the structure of objects to save in the background. Currently, data is sent directly to the Controller and stored in the database, if valid.

Now you need to perform an intermediate step: the user should be able to verify the input data before saving it in the database. If he decides that he is correct, the form data should be submitted and stored in the database; if the user decides that the form should be edited, he should be able to return to the form and correct it. (Of course, all this is in a loop until the user is satisfied with the form and submits it.)

This means that a preview page is needed. This page / action should receive data and display it somehow (in the form of a table or the same). Data needs to be temporarily stored and be prepared to β€œwet” the Form object and save. If the user wants to update the form, the form must be restored.

How can I implement this requirement?

UPDATE

I am looking for a server solution. The preview should be a new page, not an HTML version of the JavScript / client side on the same page (for tracking and other purposes).

+6
source share
2 answers

I would say that the best solution would be to implement a client (java -) script that is executed before you execute the POST form POST . You can catch the form submit event and display the client-side view in which you display the current state of all form fields (name and value). If the user clicks accept , you continue the POST operation. If the user clicks the "Cancel" button, you return to the form view, where you allow additional changes, and all this repeats.

It’s easy to find examples of how to do this ...

One example is this blog post , but there is still much to be found using Google .

0
source

Since I don’t know how your / db application is structured, I can only assume that you could create another table in which temporary data will be stored or after the user submits the form and it is validated instead of saving it in db. read-only fields and replace the original submit button with one that will save the data, and one that will return the user to a form where he / she can change the data.

0
source

All Articles