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 reset session $var (Issue / Tip)

 
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
Isidor128
Smarty Regular


Joined: 27 Jul 2004
Posts: 35
Location: France

PostPosted: Tue Sep 07, 2004 8:41 pm    Post subject: SmartyValidate reset session $var (Issue / Tip) Reply with quote

Hi,

When testing SmartyValidate, I've been enoyed a few times by the session variables still remembering the last version and not the modified one of the template.

The answer is easy close the broswer and start it again, but sometime not easy to do when debuging.

So I've tested this

[php:1:bdad4955ab]<?php
if(empty($_POST)) SmartyValidate::disconnect();

SmartyValidate::connect($smarty);
?>[/php:1:bdad4955ab]

And I think that's working, is there another way to do this ?

Reagrds
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Tue Sep 07, 2004 9:40 pm    Post subject: Reply with quote

Another option is this:

[php:1:b89e567b09]if(empty($_POST))
SmartyValidate::connect($smarty, true);[/php:1:b89e567b09]

That will essentially "reset" the default form. If you are using a form other than the default:

[php:1:b89e567b09]if(empty($_POST))
SmartyValidate::register_form('myform', true);[/php:1:b89e567b09]

Also, be sure you disconnect() after you are finished with a form.
Back to top
View user's profile Send private message Visit poster's website
Isidor128
Smarty Regular


Joined: 27 Jul 2004
Posts: 35
Location: France

PostPosted: Thu Sep 09, 2004 1:55 pm    Post subject: Reply with quote

mohrt wrote:
Another option is this:

[php:1:a8fd3bcf8f]if(empty($_POST))
SmartyValidate::connect($smarty, true);[/php:1:a8fd3bcf8f]

....


Ice tested but It works only with

[php:1:a8fd3bcf8f]
if(empty($_POST)) SmartyValidate::connect($smarty, true);
else SmartyValidate::connect($smarty);
[/php:1:a8fd3bcf8f]

or

[php:1:a8fd3bcf8f]
if(empty($_POST)) SmartyValidate::connect($smarty, true);
SmartyValidate::connect($smarty);
[/php:1:a8fd3bcf8f]

regards
Back to top
View user's profile Send private message Visit poster's website
kirk
Smarty Rookie


Joined: 10 Dec 2004
Posts: 5
Location: Vienna, Austria

PostPosted: Sun Dec 19, 2004 1:12 am    Post subject: Reply with quote

Hi mohrt,

Could you perhaps also add this info to the documentation page?

I figured this out to be useful with another scenario (and was just browsing the forum to check that the solution had not been posted before): when having multiple forms on a page the validation does not work for a form if validation has been started previously for another form.

I thought that form registration was intended for that but it did not exactly work. Only this solution did.

Additionally a useful piece of information for the docu would be that you have to remember to name your submit buttons if you also want to have validation for forms submitted without entering any data.
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