From 65d1681331f0ef8838f8f9a8285e6b3acd38eac7 Mon Sep 17 00:00:00 2001 From: ajshort Date: Mon, 19 Dec 2011 14:21:47 +1100 Subject: [PATCH 1/2] MINOR: Make the form reference consistently available on form steps. --- code/MultiForm.php | 2 ++ code/MultiFormStep.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/code/MultiForm.php b/code/MultiForm.php index 3f32923..22908ea 100644 --- a/code/MultiForm.php +++ b/code/MultiForm.php @@ -199,6 +199,8 @@ abstract class MultiForm extends Form { */ protected function setCurrentStep($step) { $this->session->CurrentStepID = $step->ID; + $step->setForm($this); + return $this->session->write(); } diff --git a/code/MultiFormStep.php b/code/MultiFormStep.php index a3b3998..c05d71c 100644 --- a/code/MultiFormStep.php +++ b/code/MultiFormStep.php @@ -263,6 +263,8 @@ class MultiFormStep extends DataObject { $steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->SessionID}", '"LastEdited" DESC'); if($steps) { foreach($steps as $step) { + $step->setForm($this->form); + if($step->getNextStep()) { if($step->getNextStep() == $this->class) { return $step->class; From 4f1510ff5b6e9dfae1fa3e1b0ee047881f058e00 Mon Sep 17 00:00:00 2001 From: ajshort Date: Mon, 19 Dec 2011 14:21:56 +1100 Subject: [PATCH 2/2] BUGFIX: Run validation on the final step. --- code/MultiForm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/MultiForm.php b/code/MultiForm.php index 22908ea..df30cb3 100644 --- a/code/MultiForm.php +++ b/code/MultiForm.php @@ -377,7 +377,13 @@ abstract class MultiForm extends Form { Director::redirectBack(); return false; } - + + if(!$this->getCurrentStep()->validateStep($data, $form)) { + Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); + Director::redirectBack(); + return false; + } + // Save the form data for the current step $this->save($data); }