How to preview information before save into database?

Im a newbie about Yii framework:(. Im having some trouble about my homework, so please help me:D

I have a form. For example Staff Manager form: Name field, Email field, Tel field.

After fill in all fields, i click button OK and then i will have a page where preview information i have inputted.

End when i click Save button in that preview page, the data will be store into database.

How to do this work? Please help me:d


I guess there are many different ways to solve this. You go with a regular form view with regular inputs, when submitted you redirect to a second view with hidden fields populated and preview of the entered data, when submitted, this will actually saves the model (from which values were populated from the hidden input fields).

Or you can store temporary inputs in user session, but I’d probably go with the 2 steps form (input fields -> hidden inputs -> store in db).



Thaks man! i will try:D

someone can give me some code? i dont know how to do this:(

Its pretty simple. You need to persist the data between pages. To do that, you either need hidden fields which contain the data that you POSTed from the 1st page, or you need to store variables in session. If you go hidden fields you should really be checking to make sure the user didn’t manipulate them when finally submitting the form.

Another way to present this to the user is in the form of a modal dialog popup window which has a ‘submit’ button to save the data, or a cancel/close to revert back to original form.

What I’ve done also is instead of having multi page workflows you can update fields with ajax calls.

In one of my forms you can ‘batch update’ information. In this app members send in dues. So instead of going to each record and editing them as paid for the year you put their ID in a field and hit ‘search’ and it populates their information into the form. So you ‘preview as you go’ instead of showing a summary of changes page.