BUGFIX validator couldn't tie itself to a form correctly, encapsulated validator setup on MultiForm->setValidator()

This commit is contained in:
Sean Harvey 2008-05-24 23:49:49 +00:00
parent 2f4e8de921
commit b0f45b505b

View File

@ -103,7 +103,7 @@ abstract class MultiForm extends Form {
$this->fields->push(new HiddenField('MultiFormSessionID', false, $this->session->$urlMethod));
// Set up validator from the form step class
$this->validator = $currentStep->getValidator();
$this->setValidator();
// If there is form data, we populate it here (CAUTION: loadData() MUST unserialize first!)
if($currentStep->loadData()) {
@ -254,6 +254,19 @@ abstract class MultiForm extends Form {
$this->fields = $fields;
}
/**
* Set up the validation for this form.
*
* We check if the validator exists first, as validation on
* each step is optional.
*/
function setValidator() {
if($validator = $this->getCurrentStep()->getValidator()) {
$this->validator = $validator;
$this->validator->setForm($this);
}
}
/**
* Set the actions for this form.
*