Jump to:

10851 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » Multiform Module 'Back' button form validation

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 531 Views
  • cwchong
    Avatar
    Community Member
    13 Posts

    Multiform Module 'Back' button form validation Link to this post

    Hi, using the multiform module, when clicking on the "Back" button of a step (say step 2), it appears that the validation rules for this current step is fired.

    Is this intended behaviour?

    It would be only possible to do a "Back" if the current step validates, is there a way to hook the back button so as not to trigger validation?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Multiform Module 'Back' button form validation Link to this post

    Defiantly a bug! Raise it as an issue on the modules issue tracker (https://github.com/silverstripe/silverstripe-multiform/issues)

  • cwchong
    Avatar
    Community Member
    13 Posts

    Re: Multiform Module 'Back' button form validation Link to this post

    Hi Will,
    tks for the reply.

    I am trying to see if I can debug that, perhaps you can help me a little.

    I am looking at the MultiForm class's "actions_exempt_from_validation" feature, at approx. line 130:

    if( $actionNames ) {
             foreach( $actionNames as $exemptAction) {
                if(!empty($_REQUEST[$exemptAction])) {
                   $applyValidation = false;
                   break;
                }
             }
          }


    It appears the code tries to check a match with exempted actions (e.g. action_prev) with the request object, but inspecting the $_REQUEST object only returns the multiformsessionid and not the posted action submit button!

    Then, I tried to inspect if the posted submit button is available via

    $currentStep->loadData();


    But this only returns the form fields' data, excluding the submit action.
    I see no other location where the submit action is inspected in the code, does that mean I have to look into the Silverstripe base Form class?

    Also, I find it quite strange that the validation exemption is performed at __construct(), is it to exclude js validation code being injected? Shouldn't it be handled in httpSubmission() instead? Since we "do" want validation if, instead of hitting the "back", we hit the "next".
    Does the __construct() here doubles as the handler for submission from the last form step?
    If so, i find it more puzzling that the "current" step validation now depends on the posted action from the previous step
    (the lines from 130 till "parent::__construct($controller, $name, $fields, $actions, $validator);")

    531 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.