I want to make a form divided into two steps - each on a separate page. Depending on the data given in the first step, i want to prepare some prefilled data in the second step.
Despite spending a lot of time searching in google I can not find it.
From a logical point of view, I would prefer one Zend\Form and separate fieldsets (??) than create two separate forms.
So how to do it correctly in Zend Framework 2?
The easiest way would (I think) to have two forms, a
MyModule\Form\Step1
and aMyModule\Form\Step2
. TheStep2
form accepts some input in the constructor which is depending on some data from step 1.An example, you can do this with the service manager's factory:
If you
GET
the page where the first one is displayed, then youPOST
to the second page and finallyPOST
to the last page. During construction of the second form, you use the POST data and populate/construct the data as needed.