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) {
$this->session->CurrentStepID = $step->ID;
$step->setForm($this);
return $this->session->write();
}
@ -376,6 +378,12 @@ abstract class MultiForm extends Form {
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);
}

View File

@ -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;