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

A few SmartyValidate questions that I didn't find in docs...

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


Joined: 06 Mar 2005
Posts: 36

PostPosted: Wed Mar 09, 2005 6:09 am    Post subject: A few SmartyValidate questions that I didn't find in docs... Reply with quote

What does $empty do? I couldn't figure out this behavior. $halt just stops processing if it failed, right?

What about having multiple errors for same element? Could I have it says "Please don't leave empty" if it's blank, and "Please use a real email address" if it's not a valid email in that same element? How?

Thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Mar 09, 2005 2:50 pm    Post subject: Reply with quote

The SmartyValidate README goes over all of this.

Sometimes you want to allow a field to be empty, or validate its contents. $empty is the value set for "empty" when you register the validator.

Example:

Code:
{validator field="foo" criteria="bar" empty="yes" ...}


inside the validator, the $empty parameter will be true or false, defaulting to false if it was not defined. Then in the criteria function you do something like:

[php:1:370bf71fad]if(strlen($field) == 0)
return $empty;[/php:1:370bf71fad]

See some of the criteria that ships with SmartyValidate for examples.
Back to top
View user's profile Send private message Visit poster's website
timmerk
Smarty Regular


Joined: 06 Mar 2005
Posts: 36

PostPosted: Wed Mar 09, 2005 6:56 pm    Post subject: Reply with quote

Hmm.. I'm not grasping this concept.. Maybe I am brain dead right now. I will continue to try to understand.

Do you mean the user can leave it empty, but if they do enter something, it will validate?

How can you have seperate error msgs for the same element like I asked too?

Thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Mar 09, 2005 7:01 pm    Post subject: Reply with quote

timmerk wrote:

Do you mean the user can leave it empty, but if they do enter something, it will validate?


That is exactly correct with empty="yes"

timmerk wrote:

How can you have seperate error msgs for the same element like I asked too?


Apply two separate validators to the same field.
Back to top
View user's profile Send private message Visit poster's website
timmerk
Smarty Regular


Joined: 06 Mar 2005
Posts: 36

PostPosted: Wed Mar 09, 2005 7:05 pm    Post subject: Reply with quote

Thanks!
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