The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Fields Variable is Empty after Validation with Error - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Fields Variable is Empty after Validation with Error (/showthread.php?tid=1326)



Fields Variable is Empty after Validation with Error - asgaroth - May 24th, 2011

Hey there,

i hope this is the right subforum to post my question to.

I've got a multipage form using the api. Everything is set up and i think is working okay.

The Problem is that if i don't enter all values that are required and submit the page, the fields array is not containing the entered values and therefore they are not reinserted into the form!

I already checked that validation is right, that all the form fields are set up like this:
Code:
<input type="text" name="name" size="30" maxlength="100" value="<?=@$fields['name']?>"/>
.

Here is the header of one of my forms (not the initial page):
Code:
<?php
require_once("../global/api/api.php");
$fields = ft_api_init_form_page();

$errors = array();
// if submitted, process the form fields
if (isset($_POST) && !empty($_POST))
{  
  $rules = array();
  $rules[] = "required,name,Please insert your Name.";
$errors = validate_fields($_POST, $rules);
}

if (empty($errors))
{
  $params = array(
    "submit_button" => "continue",
    "next_page" => "step3.php",
    "form_data" => $_POST
      );
  ft_api_process_form($params);
}

I already tried the following:

1. Verifying via var_dump that fields is really not containing the input
2. Setting $g_session_type = "database"; in the config
3. Deleting or commenting out rules with commas (because i read that this is unsupported) and with html chars like &uuml; (i need them because i am german).
4. Checked the initial page for a valid ft_api_init_form("", "test");

The var dump contains only things from the first page (there i have only 4 radio buttons to choose from so this initial page is always filled completely):

Code:
array(4) { ["form_tools_form_id"]=> string(4) "test" ["form_tools_submission_id"]=> string(4) "test" ["profil_prio"]=> string(9) "thing" ["continue"]=> string(6) "Continue" }

Thanks in advance for your replies, asgaroth!
Hey there,

i reviewed the formtools code and found myself a workaround.
Here is how it currently works (only tested in testing mode):

Code:
if (!empty($errors))
{
  $params = array(
    "submit_button" => "continue",
    "form_data" => $_POST
      );
  ft_api_process_form($params);
  $fields = ft_api_init_form_page();
}

I call ft_api_process_form without changing the page (next_page is not required as the comments in the code state) and then i reinitialize fields with ft_api_init_form_page.

Do you think i can/should keep this as workaround or is there another possibility?

Thanks in advance, asgaroth