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 Help

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


Joined: 10 Sep 2003
Posts: 38

PostPosted: Sun Jun 13, 2004 1:06 am    Post subject: SmartyValidate Help Reply with quote

Hey, I'm upgrading from an older version and some of the commands have changed. What I am wondering is how to I "register" a form? Can you give an example of smartyvalidate with a registered form?

Command in Question: register_form

Thanks to anyone who replies.
Back to top
View user's profile Send private message
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Sun Jun 13, 2004 1:30 am    Post subject: Reply with quote

Also, can you show a example of "{$validate.default.is_error}".
I though all I had to do was put it in the template and it'd show either 1 or 0. But that isn't working...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Sun Jun 13, 2004 2:34 am    Post subject: Reply with quote

SmartyValidate::register_form('myform');

That will register a form. Then in the template you use:

{validate form="myform" ... }

And when you post the form:

if(SmartyValidate::is_valid($_POST,'myform')) { ... }

will execute if the form info is valid.

The {validate.myform.is_error} is a boolean value, so (I think) it will display "1" when true and "" (not 0) when false.
Back to top
View user's profile Send private message Visit poster's website
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Sun Jun 13, 2004 2:37 am    Post subject: Reply with quote

Okay, do I do the set register_form before or after the if(empty($_POST){

I assume before or just after the connect command...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Sun Jun 13, 2004 3:06 am    Post subject: Reply with quote

set it right before displaying the form. each time you call register_form() it essentially "resets" it. (use the latest CVS to be sure, reset_form() was removed) Don't call it between form submits though, just upon the initial form entry (or you leave the form and come back)
Back to top
View user's profile Send private message Visit poster's website
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Sun Jun 13, 2004 4:11 am    Post subject: Reply with quote

Okay, now how do I say the form name? var "fp"? like in older versions or set it in the <form name="" action...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Sun Jun 13, 2004 6:43 am    Post subject: Reply with quote

ThermoDust wrote:
Okay, now how do I say the form name? var "fp"? like in older versions or set it in the <form name="" action...


You only have to put the form name in the validate tags:

{validate form="myform" ... }

After you submit the form, you use is_valid() with the $_POST info :

if ( SmartyValidate::is_valid($_POST, 'myform') ) { ... }
Back to top
View user's profile Send private message Visit poster's website
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Sun Jun 13, 2004 8:09 pm    Post subject: Reply with quote

Is there any way to have it validate using mutiple methods? Like for the password have it match the password and confirm password and have it set a min and max length?
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Mon Jun 14, 2004 2:08 am    Post subject: Reply with quote

Use multiple {validate ... } tags on the same form element. They are checked in order.
Back to top
View user's profile Send private message Visit poster's website
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Mon Jun 14, 2004 7:52 am    Post subject: Reply with quote

You should make a FAQ about this Mohrt Smile
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