I'm doing a form that has 3 steps. The first step has a next button. The second step has a button back and next button. Finally the third step, has a button back and submit (to do something).
I'm thinking that a good way to move between steps would be handling objects. With a single controller with three methods for the three steps.
I think a good way to move between steps (saving data) would be handling objects in a parent object (that encapsulates the objects).
My logic is:
First step: I have no saved object. When I click on the next button, I save the data from step one in an "object A".
Second step: I have the "object A" saved (with data from the first step). If I click the Back button I go back to step one (obviously), but I lose the "object A". If I click on the next button I'm going to step three with the "object A" + "object B" (with data from the second step).
Third step: I have the "object A" and "object B" saved. If I click the back button I go back to step two, but I lose the "object B". If I click on the submit button I have the objects A + B + C saved.
So, I want encapsulate objects in a parent object.
Is important to say that in all steps I get information from different tables of the database.
Someone have a good example with this logic? Thanks.