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.

All other Modules

Discuss all other Modules here.

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

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


Reply

2 Posts   607 Views

Avatar
Ben_W

6 May 2013 at 12:59pm Community Member, 80 Posts

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

6 May 2013 at 3:22pm (Last edited: 8 May 2013 5:12pm), Community Member, 80 Posts

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.