mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 09:05:49 +00:00
BUGFIX validator couldn't tie itself to a form correctly, encapsulated validator setup on MultiForm->setValidator()
This commit is contained in:
parent
2f4e8de921
commit
b0f45b505b
@ -103,7 +103,7 @@ abstract class MultiForm extends Form {
|
|||||||
$this->fields->push(new HiddenField('MultiFormSessionID', false, $this->session->$urlMethod));
|
$this->fields->push(new HiddenField('MultiFormSessionID', false, $this->session->$urlMethod));
|
||||||
|
|
||||||
// Set up validator from the form step class
|
// 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 there is form data, we populate it here (CAUTION: loadData() MUST unserialize first!)
|
||||||
if($currentStep->loadData()) {
|
if($currentStep->loadData()) {
|
||||||
@ -254,6 +254,19 @@ abstract class MultiForm extends Form {
|
|||||||
$this->fields = $fields;
|
$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.
|
* Set the actions for this form.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user