Form Tools
Validation clearing all data! - 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: Validation clearing all data! (/showthread.php?tid=2956)



Validation clearing all data! - geekkeeg - Mar 13th, 2014

Hello all. I've got some validation on my form and it works beautifully. Problem is that every time there's an error, the data is not retained in the form, causing the users to have to re-enter it every time.

Here's my pertinent code:
<?php
require_once("/wamp/www/ah/global/api/api.php");
$fields = ft_api_init_form_page(5, "live", "form5");

$errors = array();
if (isset($_POST["submit"]))
{
$rules = array();
$rules[] = "if:element_27!=,required,element_57,Please enter misc details.";
$errors = validate_fields($_POST, $rules);

$criteria = array(
"col_2" => $_POST["element_1"],
"col_1" => $_POST["element_22"]
);
if (!ft_api_check_submission_is_unique(5, $criteria, $fields["form_tools_submission_id"]))
{
$errors[] = "Sorry, you have already placed a submission for this date range. Please contact the appropriate staff to modify your previous entry.";
}

if (empty($errors))
{
$params = array(
"namespace" => "form5",
"submit_button" => "submit",
"next_page" => "thankyouhims.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
else
{

$fields = array_merge($_SESSION["form_tools_form"], $_POST);
}
}
?>


Help!


RE: Validation clearing all data! - Joe - Mar 20th, 2014

In the markup on your form are you outputting the values?

For example:

<input type="text" name="firstname" size="25" maxlength="50" value="<?php echo htmlspecialchars($fields['firstname'])?>" />

Cheers,

Joe


RE: Validation clearing all data! - geekkeeg - Mar 24th, 2014

Nope! I'll give that a shot and report back.

Thanks!


RE: Validation clearing all data! - geekkeeg - Mar 25th, 2014

Totally worked. Thanks!


RE: Validation clearing all data! - Joe - Mar 25th, 2014

No worries!

Cheers,

Joe