Merge pull request #1 from ajshort/master

BUGFIX Make The Controller And Form Name Available For Field Construction
This commit is contained in:
Ingo Schommer 2011-05-27 15:14:47 -07:00
commit c73082e2ab

View File

@ -86,7 +86,12 @@ abstract class MultiForm extends Form {
if(isset($_GET['MultiFormSessionID'])) { if(isset($_GET['MultiFormSessionID'])) {
$this->setCurrentSessionHash($_GET['MultiFormSessionID']); $this->setCurrentSessionHash($_GET['MultiFormSessionID']);
} }
// First set the controller and name manually so they are available for
// field construction.
$this->controller = $controller;
$this->name = $name;
// Set up the session for this MultiForm instance // Set up the session for this MultiForm instance
$this->setSession(); $this->setSession();
@ -398,8 +403,11 @@ abstract class MultiForm extends Form {
return false; return false;
} }
// custom validation (use MultiFormStep->getValidator() for built-in functionality) // Perform custom step validation (use MultiFormStep->getValidator() for
// built-in functionality). The data needs to be manually saved on error
// so the form is re-populated.
if(!$this->getCurrentStep()->validateStep($data, $form)) { if(!$this->getCurrentStep()->validateStep($data, $form)) {
Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
Director::redirectBack(); Director::redirectBack();
return false; return false;
} }