I have a multi-part form where the flow of the data is:
- Answer the form, SUBMIT (via ajax post)
- jQuery Form and CodeIgniter validation echoed if present
- Preview the answers from the form
- Choices: Cancel, Edit, Commit to database
The three choices are submit buttons with unique names in the preview form. My Commit to database process is finished, while I have difficulty in doing the Cancel and Edit. My current method for the three are (inside the controller):
function preview_form_redirect()
{
if ( isset($_POST['submit-form']) ) {
$this->send_to_database();
} else if ( isset($_POST['edit-form']) ) {
// return to form with all answers intact
} else { // CANCEL FORM
redirect('accounts');
}
} // END preview_form_redirect()
My plan for the Edit option is to simulate back button because I'm sure the data and DOM will be intact.
I know my methods for the two are not perfect but I am stuck and do not know what other methods to simulate the two. Are there possible and compatible ways to do the two for my setup?