Merge pull request #2 from ajshort/silverstripe-multiform

---
This commit is contained in:
Ingo Schommer 2011-12-19 10:46:39 +01:00
commit 158f4a1bd3
2 changed files with 11 additions and 1 deletions

View File

@ -199,6 +199,8 @@ abstract class MultiForm extends Form {
*/ */
protected function setCurrentStep($step) { protected function setCurrentStep($step) {
$this->session->CurrentStepID = $step->ID; $this->session->CurrentStepID = $step->ID;
$step->setForm($this);
return $this->session->write(); return $this->session->write();
} }
@ -375,7 +377,13 @@ abstract class MultiForm extends Form {
Director::redirectBack(); Director::redirectBack();
return false; 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 // Save the form data for the current step
$this->save($data); $this->save($data);
} }

View File

@ -263,6 +263,8 @@ class MultiFormStep extends DataObject {
$steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->SessionID}", '"LastEdited" DESC'); $steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->SessionID}", '"LastEdited" DESC');
if($steps) { if($steps) {
foreach($steps as $step) { foreach($steps as $step) {
$step->setForm($this->form);
if($step->getNextStep()) { if($step->getNextStep()) {
if($step->getNextStep() == $this->class) { if($step->getNextStep() == $this->class) {
return $step->class; return $step->class;