View previous topic :: View next topic |
Author |
Message |
tangfucius Smarty Rookie
Joined: 30 Sep 2004 Posts: 16
|
Posted: Mon Nov 14, 2005 6:31 am Post subject: SmartyValidate - serious problems with browser "Back&qu |
|
|
SmartyValidate is nice and powerful.
However here is one of the serious problem that I ran into:
Whenever I'm on a page with smartyvalidate, say the first time my input doesn't validate, I put in the correct data, and click on submit, my page validates the data and goes to the next page. Now if I click on the browser's "Back" button, it asks me if I want to re-submit the post data, I click on "Yes", I get a nasty form of "SmartyValidate validator not registered" errors.
Is there anyway to fix this??? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Nov 14, 2005 2:43 pm Post subject: |
|
|
Put some checks in your PHP logic before displaying the form... if the form is not registered, then do something about it before displaying. |
|
Back to top |
|
tangfucius Smarty Rookie
Joined: 30 Sep 2004 Posts: 16
|
Posted: Mon Nov 14, 2005 10:41 pm Post subject: |
|
|
that would require add the checks JUST for smartyvalidate in every single page that uses it, it can easily become a nightmare.
is that how you personally deal with this problem? is there better ways? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Nov 15, 2005 3:08 am Post subject: |
|
|
I test that the form is registered before the form is drawn. I don't recall that being a nightmare. |
|
Back to top |
|
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Mon Nov 21, 2005 5:48 am Post subject: |
|
|
mohrt wrote: | I test that the form is registered before the form is drawn. I don't recall that being a nightmare. |
That nightmare part makes me laugh out loud everytime I read it. |
|
Back to top |
|
cc96ai Smarty n00b
Joined: 05 Dec 2005 Posts: 3 Location: Toronto, Canada
|
Posted: Mon Dec 05, 2005 8:58 pm Post subject: |
|
|
mohrt wrote: | I test that the form is registered before the form is drawn. I don't recall that being a nightmare. |
I try to put is_registered_object
however the error come from tpl,
can I know how to test on it?
Thanks
-------------------
www.digitmind.com |
|
Back to top |
|
sguillory6 Smarty Rookie
Joined: 20 Feb 2006 Posts: 17
|
Posted: Wed May 03, 2006 9:12 am Post subject: Smarty Validate and back button/reload |
|
|
I ran into the same issue, and if you code your smarty setup according to the example in the documentation it is unavoidable. I now structure my code like this:
$smarty = new MySmarty();
if (empty($_POST)) {
setupSmarty($smarty);
/* do other stuff, forward to template form */
}
else {
setupSmarty($smarty);
if (is_valid($_POST)) {
/* process form */
}
else {
/* assign $_POST, etc */
}
}
function setupSmarty(& $smarty) {
if (is_registered_form('default')) {
SmartyValidate::connect($smarty);
}
else {
SmartyValidate::connect($smarty, true);
/* register validators */
}
}
Is this pretty much the way people are handling this?
Thanks,
Stan
} |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Wed May 03, 2006 12:53 pm Post subject: Re: Smarty Validate and back button/reload |
|
|
Hi,
you call your "setupSmarty($smarty);" in the >if< and also in the >else< part of your if. So you can it also move it in front of the if-clause..
Bye,
Markus |
|
Back to top |
|
sguillory6 Smarty Rookie
Joined: 20 Feb 2006 Posts: 17
|
Posted: Thu May 04, 2006 4:47 am Post subject: |
|
|
The duplication was intentional to demonstrate that:
1) The registration of validators has *nothing* to do with whether the PHP script was called with a POST HTTP request or a GET HTTP request
and
2) The lone example in the online documentation is not particularly realistic.
So are you guys going to provide a more useful "starting" example now?
:*)
Stan |
|
Back to top |
|
gis Smarty n00b
Joined: 24 May 2006 Posts: 1
|
Posted: Sun Sep 17, 2006 2:29 pm Post subject: aaaagh! |
|
|
i tried for a while to implement this SmartyValidate, but i couldn't work-around the "back button" problem...
unless this SmartyValidate is properly documented with a fully working example, i can't use it. i am a bit disappointed that this website advertises SmartyValidate that is 100% useless for 90% of all coders.
PS:
please prove me wrong. |
|
Back to top |
|
|