|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
svylbowe Smarty n00b
Joined: 16 Dec 2004 Posts: 1
|
Posted: Thu Dec 16, 2004 5:17 pm Post subject: problem with smartyvalidate |
|
|
Hi,
we're using Smarty for a professional site with lots of forms. Nearly every page has one form and they all require validation. We use SmartyValidate, which we think is promising.
Unfortunately, we've run into problems, when we go from one form-page to another. Sometimes the validation-criteria follow the user to the next page, and we get errors since the validation-criteria from the previous form aren't fullfilled in the new form.
We're following the readme-file very closely:
session_start();
require('Smarty.class.php');
require('SmartyValidate.class.php');
$smarty =& new Smarty;
// required initialization
SmartyValidate::connect($smarty);
if(empty($_POST)) {
$smarty->display('form.tpl');
} else {
// validate after a POST
if(SmartyValidate::is_valid($_POST)) {
// no errors, done with SmartyValidate
SmartyValidate::disconnect(); <- should reset
$smarty->display('success.tpl');
} else {
// error, redraw the form
$smarty->assign($_POST);
$smarty->display('form.tpl');
}
}
We've tried giving the forms different names and registering them with smartyvalidate with the command:
SmartyValidate::register_form('myform', true);
But that doesn't help!??!
Has anyone stumbled across this problem and some likely solutions? We couldn't find anything in the forum that helps.
Please help, we'd hate to give up SmartyValidate because of this, but we have a deadline in the beginning of january.
J.S. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Dec 16, 2004 7:18 pm Post subject: |
|
|
If the user is never validating more than one form at any given time, then naming each form separately shouldn't be necessary. The important thing is to reset the validation data anytime you start a new form.
SmartyValidate::reset();
That should wipe out any existing form validation info. Resetting the validation data via SmartyValidate::disconnect() may not be reliable since the user may not always finish a given form. |
|
Back to top |
|
Sesswanna Smarty n00b
Joined: 17 Dec 2004 Posts: 4
|
Posted: Fri Dec 17, 2004 1:33 am Post subject: |
|
|
I have tried to copy and paste Code: | SmartyValidate::reset(); | into my code, but all I get is Quote: | Fatal error: Call to undefined function: reset() in c:\inetpub\wwwroot\savvysurveyor\index.php on line 36 |
I have just started using Smarty and SmartyValidate today, so I could be missing something fairly obvious.
I have version 2.2 of SmartyValidate and version 2.6.6 of Smarty installed. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Dec 17, 2004 2:35 pm Post subject: |
|
|
oops, I was thinking of another add-on. use
SmartyValidate::connect($smarty, true);
That will reset the form validation session data. Only set the "true" flag on the initial drawing of a form (not every invocation.) Alternately:
SmartyValidate::register_form('default',true);
will also reset the session data for the given form name. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|