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

Multiform Module 'Back' button form validation


Reply


3 Posts   751 Views

Avatar
cwchong

Community Member, 13 Posts

5 September 2012 at 1:37pm

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?

Avatar
Willr

Forum Moderator, 5513 Posts

7 September 2012 at 10:11pm

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

Avatar
cwchong

Community Member, 13 Posts

12 September 2012 at 5:33am

Edited: 12/09/2012 6:11am

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);")