Jump to:

10993 Posts in 2727 Topics by 1818 members

All other Modules

SilverStripe Forums » All other Modules » [Solved] Form validation error message in MultiForm, SilverStripe 3

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 594 Views
  • Ben_W
    Avatar
    Community Member
    80 Posts

    [Solved] Form validation error message in MultiForm, SilverStripe 3 Link to this post

    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

  • Ben_W
    Avatar
    Community Member
    80 Posts

    Re: [Solved] Form validation error message in MultiForm, SilverStripe 3 Link to this post

    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.

    594 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.