formtools / core

The Form Tools Core.
https://formtools.org
207 stars 78 forks source link

Files are "lost" in multi-page forms #809

Open radasys opened 3 years ago

radasys commented 3 years ago

Hi! We have been trying to configure multi-page forms through the API.

Our form is very simple, it has only two pages. In the first one, the user fills personal data and upload files. In the second page, the user reviews the information and click a Send button.

When configuring multi-page forms through the FormTools Admin Panel, we have noticed that the file upload fields do not appear after submitting the test submission.

Here you have a few PHP snippets that may be helpful:

Page 1: Filling information

<?php
require_once("formtools/global/api/API.class.php");
$api = new FormTools\API();
$fields = $api->initFormPage(5, "initialize");
$params = array(
  "submit_button" => "siguiente",
  "next_page" => "nextPage.php",
  "form_data" => $_POST,
  "file_data" => $_FILES,
  "has_captcha" => true
);
$api->processFormSubmission($params);
?>

Page 2: Review page

<?php
require_once("formtools/global/api/API.class.php");
$api = new FormTools\API();
$fields = $api->initFormPage();
$params = array(
  "submit_button" => "enviar",
  "next_page" => "gracias.php",
  "form_data" => $_POST,
  "file_data" => $_FILES,
  "finalize" => true,
  "no_sessions_url" => "firstPage.php"
);
$api->processFormSubmission($params);
?>

Could you give us further assistance?

Thanks!

radasys commented 3 years ago

Please notice that if we set up the form as a single page form in FormTools Admin Panel, we can submit all the files without issues.

If we then manually change PHP code to switch to a multipage form (that's changing the next_page and finalize parameters), the form still works (we can submit all the text and file fields).

Thank you for your assistance.