Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[Solved] Form validation error message in MultiForm, SilverStripe 3


Go to End


2 Posts   1842 Views

Avatar
Ben_W

Community Member, 80 Posts

6 May 2013 at 12:59pm

I have been working on this MultiForm on SilverStripe 3. Using the example from https://github.com/silverstripe/silverstripe-multiform, I added the form validation for the step one, i.e.

public function getValidator() {
$validator = new RequiredFields(array('AreaToStudyIn'));
return $validator;
}

the error message appears all right under the text field as expected, however, after fill in some value and continue to next step, this error message remain on the form, even after the form being submitted completely. One thing I do notice is that the validation error message is not coming from javascript validation, because the page is reloaded then comes the error message.

Has anyone tried to set the validation on MultiForm? Thank you for taking the time to read this :)

Avatar
Ben_W

Community Member, 80 Posts

6 May 2013 at 3:22pm

Edited: 08/05/2013 5:12pm

There is a post about this behaviour on the MultiForm github page:
https://github.com/silverstripe/silverstripe-multiform/issues/12

To work around this for now, add the following in your step's getFields or at any point before the form is validated:

if(isset($_SESSION['FormInfo']['EPMultiForm_EPMultiForm']['errors'])){
unset($_SESSION['FormInfo']['EPMultiForm_EPMultiForm']['errors']);
}

where 'EPMultiForm_EPMultiForm' needs to be your form name.