|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Wed Mar 09, 2005 6:09 am Post subject: A few SmartyValidate questions that I didn't find in docs... |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 09, 2005 2:50 pm Post subject: |
|
|
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 |
|
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Wed Mar 09, 2005 6:56 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 09, 2005 7:01 pm Post subject: |
|
|
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 |
|
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Wed Mar 09, 2005 7:05 pm Post subject: |
|
|
Thanks! |
|
Back to top |
|
|
|
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
|