Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartyValidate - serious problems with browser "Back&qu

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
tangfucius
Smarty Rookie


Joined: 30 Sep 2004
Posts: 16

PostPosted: Mon Nov 14, 2005 6:31 am    Post subject: SmartyValidate - serious problems with browser "Back&qu Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Nov 14, 2005 2:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
tangfucius
Smarty Rookie


Joined: 30 Sep 2004
Posts: 16

PostPosted: Mon Nov 14, 2005 10:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 15, 2005 3:08 am    Post subject: Reply with quote

I test that the form is registered before the form is drawn. I don't recall that being a nightmare.
Back to top
View user's profile Send private message Visit poster's website
timmerk
Smarty Regular


Joined: 06 Mar 2005
Posts: 36

PostPosted: Mon Nov 21, 2005 5:48 am    Post subject: Reply with quote

mohrt wrote:
I test that the form is registered before the form is drawn. I don't recall that being a nightmare.


Laughing

That nightmare part makes me laugh out loud everytime I read it. Very Happy
Back to top
View user's profile Send private message
cc96ai
Smarty n00b


Joined: 05 Dec 2005
Posts: 3
Location: Toronto, Canada

PostPosted: Mon Dec 05, 2005 8:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
sguillory6
Smarty Rookie


Joined: 20 Feb 2006
Posts: 17

PostPosted: Wed May 03, 2006 9:12 am    Post subject: Smarty Validate and back button/reload Reply with quote

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
View user's profile Send private message Send e-mail
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Wed May 03, 2006 12:53 pm    Post subject: Re: Smarty Validate and back button/reload Reply with quote

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
View user's profile Send private message
sguillory6
Smarty Rookie


Joined: 20 Feb 2006
Posts: 17

PostPosted: Thu May 04, 2006 4:47 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
gis
Smarty n00b


Joined: 24 May 2006
Posts: 1

PostPosted: Sun Sep 17, 2006 2:29 pm    Post subject: aaaagh! Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP