From a8877b780f7a8a2e4fd83e7bd7905efb5fd35e1f Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 1 Oct 2008 22:18:44 +0000 Subject: [PATCH] ENHANCEMENT Made MultiForm->prev() do the same behaviour for saving data as MultiForm->next() --- code/MultiForm.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/MultiForm.php b/code/MultiForm.php index fdf0a61..72cdc5b 100644 --- a/code/MultiForm.php +++ b/code/MultiForm.php @@ -386,16 +386,16 @@ abstract class MultiForm extends Form { * @param object $form The form that the action was called on */ public function prev($data, $form) { - if(!$this->getCurrentStep()->getPreviousStep() && !$this->getCurrentStep()->canGoBack()) { + // Get the previous step class + $prevStepClass = $this->getCurrentStep()->getPreviousStep(); + + if(!$prevStepClass && !$this->getCurrentStep()->canGoBack()) { Director::redirectBack(); return false; } - - // Switch the step to the previous! - $prevStepClass = $this->getCurrentStep()->getPreviousStep(); // Save the form data for the current step - $this->save($data); + $this->save($form->getData()); // Get the previous step of the class instance returned from $currentStep->getPreviousStep() $prevStep = DataObject::get_one($prevStepClass, "SessionID = {$this->session->ID}");