I've been working to combine validation along with ft_api_check_submission_is_unique and while it all works -- the values no longer stay in the fields on an error submission. If you remove the ft_api_check_submission_is_unique portion, it works fine.
EDIT: I had to adjust the live example link...
Here's the live example: http://fasports.com/az/phx/tournaments/t...r_TEST.php
And here's the code...
And the code for the same thing but without the ft_api_check_submission_is_unique:
I'm assuming there's some portion of code missing that's not relaying the values in an errored submission... but I just have no idea what that might be.
Thanks!
EDIT: I had to adjust the live example link...
Here's the live example: http://fasports.com/az/phx/tournaments/t...r_TEST.php
And here's the code...
PHP Code:
require_once("[PATH TO]/global/api/api.php");
if($ft_initialize == "yes") { $fields = ft_api_init_form_page($ft_id, "initialize"); }
else { $fields = ft_api_init_form_page($ft_id); }
// $fields = ft_api_init_form_page($ft_id); // placeholder as it's defined above
$already_exists = "";
// validation time!
$errors = array();
if (isset($_POST['submit']))
{
$rules = array();
$rules[] = "required,Team_Name,Please enter your team name.";
$rules[] = "required,Email_Address,Please enter your email address.";
$rules[] = "required,Captains_First_Name,Please enter your captain's first name.";
$rules[] = "required,Captains_Last_Name,Please enter your captain's last name.";
$rules[] = "required,Phone_Number,Please enter your phone number.";
$rules[] = "required,Terms_and_Conditions,Please confirm you have read and agree to the terms and conditions.";
$errors = validate_fields($_POST, $rules);
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
{
$params = array(
"submit_button" => "submit",
"next_page" => "reg_confirm_new.php",
"form_data" => $_POST,
"finalize" => true
);
$criteria = array(
"col_2" => $_POST["Team_Name"]
);
if (!ft_api_check_submission_is_unique($ft_id, $criteria, $fields["form_tools_submission_id"]))
{
// uh-oh! A submission already exists with this email address! Abort, abort!
// here, you could do something like set a variable like: $already_exists = true
// and in the webpage do a little test to see if it's set. If so, let the user know
// what's going on
$already_exists = true;
}
else
{
// call ft_api_process_form function here to continue processing the form submission
ft_api_process_form($params);
} } } }
And the code for the same thing but without the ft_api_check_submission_is_unique:
PHP Code:
require_once("[PATH TO]/manager/registration/global/api/api.php");
if($ft_initialize == "yes") { $fields = ft_api_init_form_page($ft_id, "initialize"); }
else { $fields = ft_api_init_form_page($ft_id); }
// $fields = ft_api_init_form_page($ft_id); // placeholder as it's defined above
$already_exists = "";
// validation time!
$errors = array();
if (isset($_POST['submit']))
{
$rules = array();
$rules[] = "required,Team_Name,Please enter your team name.";
$rules[] = "required,Email_Address,Please enter your email address.";
$rules[] = "required,Captains_First_Name,Please enter your captain's first name.";
$rules[] = "required,Captains_Last_Name,Please enter your captain's last name.";
$rules[] = "required,Phone_Number,Please enter your phone number.";
$rules[] = "required,Terms_and_Conditions,Please confirm you have read and agree to the terms and conditions.";
$errors = validate_fields($_POST, $rules);
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
{
$params = array(
"submit_button" => "submit",
"next_page" => "reg_confirm_new.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
$fields = array_merge($fields, $_SESSION["form_tools_form"]);
}
else
$fields = array_merge($fields, $_POST);
}
I'm assuming there's some portion of code missing that's not relaying the values in an errored submission... but I just have no idea what that might be.
Thanks!