BUGFIX #4480 MultiForm::next() and MultiForm::prev() now save the form data before checking the next or previous step

This commit is contained in:
Sean Harvey 2010-01-10 00:57:33 +00:00
parent cbc7d246ac
commit 794e74bebe

View File

@ -387,6 +387,8 @@ abstract class MultiForm extends Form {
* @param object $form The form that the action was called on * @param object $form The form that the action was called on
*/ */
public function next($data, $form) { public function next($data, $form) {
// Save the form data for the current step
$this->save($form->getData());
// Get the next step class // Get the next step class
$nextStepClass = $this->getCurrentStep()->getNextStep(); $nextStepClass = $this->getCurrentStep()->getNextStep();
@ -402,9 +404,6 @@ abstract class MultiForm extends Form {
return false; return false;
} }
// Save the form data for the current step
$this->save($form->getData());
// Determine whether we can use a step already in the DB, or have to create a new one // Determine whether we can use a step already in the DB, or have to create a new one
if(!$nextStep = DataObject::get_one($nextStepClass, "SessionID = {$this->session->ID}")) { if(!$nextStep = DataObject::get_one($nextStepClass, "SessionID = {$this->session->ID}")) {
$nextStep = new $nextStepClass(); $nextStep = new $nextStepClass();
@ -431,6 +430,9 @@ abstract class MultiForm extends Form {
* @param object $form The form that the action was called on * @param object $form The form that the action was called on
*/ */
public function prev($data, $form) { public function prev($data, $form) {
// Save the form data for the current step
$this->save($form->getData());
// Get the previous step class // Get the previous step class
$prevStepClass = $this->getCurrentStep()->getPreviousStep(); $prevStepClass = $this->getCurrentStep()->getPreviousStep();
@ -439,9 +441,6 @@ abstract class MultiForm extends Form {
return false; return false;
} }
// Save the form data for the current step
$this->save($form->getData());
// Get the previous step of the class instance returned from $currentStep->getPreviousStep() // Get the previous step of the class instance returned from $currentStep->getPreviousStep()
$prevStep = DataObject::get_one($prevStepClass, "SessionID = {$this->session->ID}"); $prevStep = DataObject::get_one($prevStepClass, "SessionID = {$this->session->ID}");