I am building a custom validation for the multiform module
I am using version 3.0.8 but have also tried on branch 1.0
My steps to reproduce this issue are:
* on ExampleMultiFormEligibility type in a country and in ResidencyStatus type resident
* on the next page click back button on the form
* change resident to "test"
(a this point it will fail the validation ExampleMultiFormEligibility_Validator)
* The ExampleMultiFormEligibility form is built, the value I typed "test" is lost and my previous value "resident" (the one saved on the DB) is loaded into the form
The expected result would be that if the validation failed, the form should load and the "test" string appear in the form through Session data.
Anyone else has had a similar issue?
The example code I've used is the one below:
<?php
class ExampleMultiForm extends MultiForm {
public static $start_step = 'ExampleMultiFormEligibility';
}
class ExampleMultiFormStep extends MultiFormStep {
}
class ExampleMultiFormEligibility extends ExampleMultiFormStep {
public static $next_steps = 'ExampleMultiFormDetails';
/**
* [getFields description]
* @return [type] [description]
*/
public function getFields() {
return new FieldList(
new TextField('Country', 'Country'),
new TextField('ResidencyStatus', 'Residency status')
);
}
public function getValidator() {
return new ExampleMultiFormEligibility_Validator();
}
}
class ExampleMultiFormEligibility_Validator extends Validator {
const ERROR = 'error';
public function php($data) {
$valid = true;
if($data['ResidencyStatus'] != 'resident') {
$valid = false;
$this->validationError('ResidencyStatus', 'Residency status must be resident', self::ERROR);
}
return $valid;
}
}