Forums

Server side validation with multipage form

studiocardo 08 Oct, 2014
Hi Bob

I followed your instructions in the FAQ "How to sanitize my form data" for my multipage form, and I am running into some problems.

When I did a

pr($form->data)

in my custom code, only the elements from the last page showed up. I understand I need to add a "Multi Page (reset=no" action to the On Submit event, and I can assure that is done (see attachment). But for some reason the $form->data just does not have any of the elements from previous pages. As a result, the validation code returns "undefined index" when it reaches these lines:

$form->data[$v] = filter_var($form->data[$v], FILTER_SANITIZE_STRING);
$form->data[$v] = xss_clean( $form->data[$v] );

The form has no idea what $form->data[$v] means… ???!!!!

However, the ensuing debugger output clearly displays every element with its respective value, and the form was able to post the data to the table in the DB… But it can't be validated…

Please help!
SH
GreyHead 09 Oct, 2014
Hi SH,

There's no attachment but it sounds as though you have the Multi Page action after the action where you are running the sanitization code so only the current page data is available.

That's probably OK as you don't need to re-sanitize the data from previous pages if that has already been done.

Bob
studiocardo 09 Oct, 2014
Hi Bob

Where did the attachment go?😟

You were right on! The Custom Code was indeed the first action in the On Submit event, and it was followed by Multi Page. I rearranged the order to be:

Multi page
Array Handle
Custom code
debugger


And it's working as it should.

Thank you for your help!!
SH
GreyHead 10 Oct, 2014
Hi SH,

In this forum you have to Upload the attachment **before** you Submit the post otherwise it is lost. Has caught me out several times :-(

Bob
This topic is locked and no more replies can be posted.