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: a simple yet powerful form validation plugin
Goto page Previous  1, 2, 3, 4, 5, 6 ... 16, 17, 18  Next
 
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
mohrt
Administrator


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

PostPosted: Wed Jun 09, 2004 3:01 pm    Post subject: Reply with quote

I'm thinking of adding a "halt" parameter. example:

{validate ... field="foo" halt=true message="foo is wrong"}
{validate ... field="bar" halt=true message="bar is wrong"}
{validate ... field="blah" halt=true message="blah is wrong"}

When one validator fails, it would halt execution of any more validators on the form. This way you can get the error message from the first validator if they all would fail.

My question, would it be better to default the value of halt to true or false? In otherwords, when a validator fails, should the rest of the validators be tested (by default) ?

An alternative would be the opposite approach:

{validate ... field="foo" continue=true}
{validate ... field="bar" continue=true}
{validate ... field="blah"}

This implies that validators do not continue (same as halt) by default, and you must specify that they do.
Back to top
View user's profile Send private message Visit poster's website
hihat
Smarty Rookie


Joined: 02 May 2004
Posts: 7

PostPosted: Wed Jun 09, 2004 3:11 pm    Post subject: Reply with quote

would be a nice feature as well.
I would expect the validation to test all fields as a default (so the user can correct any bad field in one go).

halt better than continue.
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Jun 10, 2004 2:40 pm    Post subject: Reply with quote

2.1 beta 1 is now available from the website. I moved from 2.0 to 2.1 since some features were added.

You can now register objects with SmartyValidate and use them as custom criteria:

// in PHP script
SmartyValidate::connect($smarty);
SmartyValidate::register_object('myobj',$myobj);
SmartyValidate::register_criteria('myobj->foobar');

// in template
{validate ... criteria="isCustom" function="myobj->foobar"}

http://www.phpinsider.com/php/code/SmartyValidate/
Back to top
View user's profile Send private message Visit poster's website
hihat
Smarty Rookie


Joined: 02 May 2004
Posts: 7

PostPosted: Thu Jun 10, 2004 3:56 pm    Post subject: Reply with quote

from NEWS
------------
Quote:
"* use message from validator tag instead of session so updates are seen (monte)"


That's good news. Now I know what I spent my last hour yesterday with.
thanks...
Back to top
View user's profile Send private message
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Thu Jun 10, 2004 4:31 pm    Post subject: Reply with quote

mohrt wrote:
My question, would it be better to default the value of halt to true or false? In otherwords, when a validator fails, should the rest of the validators be tested (by default) ?


Default it to false, because i would also want to report ALL errors @ once instead of pumping stress into my visitors if they had to enter 20 times a new field Wink


Last edited by xces on Thu Jun 10, 2004 4:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Jun 10, 2004 4:40 pm    Post subject: Reply with quote

Yes, halt defaults to false.

Next release, SmartyValidate will handle arrays of data correctly. Specifically, transformations and criteria will be applied to each element of an array. Criteria will fail if any element fails. Of course, you will be able to specify if you really want the entire array applied to the criteria/transform:

{validate ... criteria="@notEmpty"}

I have it working, just need to clean some things up.
Back to top
View user's profile Send private message Visit poster's website
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Thu Jun 10, 2004 4:43 pm    Post subject: Reply with quote

Ehm.. hehe *gulp* i am from holland, can you explain a bit more please? it is a bit technical atm Smile
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Jun 10, 2004 4:45 pm    Post subject: Reply with quote

xces wrote:

B.t.w. why do you use |escape in the example documentation? I don't really get the idea of that.


You should always HTML escape variables that are in form text input or text areas. That way special chars won't screw it up.

Example:

$myvar = This is a "test" yeah

<input type="text" value="{$myvar}">

will result in:

<input type="text" value="This is a "test" yeah">

which of course will not work.
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: Thu Jun 10, 2004 4:51 pm    Post subject: Reply with quote

xces wrote:
Ehm.. hehe *gulp* i am from holland, can you explain a bit more please? it is a bit technical atm Smile


If you have form element like such:

<input type="text" name="foo[]">
<input type="text" name="foo[]">
<input type="text" name="foo[]">

The result will be an array of values. If you apply a validator on that field:

{validate field="foo" transform="trim" criteria="notEmpty"}

Of course you don't want to trim the array, you want the elements trimmed. likewise you don't want to see if the array is empty, you want to see if any of the elements are empty.
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: Thu Jun 10, 2004 8:41 pm    Post subject: Reply with quote

There is now a SmartyValidate repository for those that want the bleeding-edge version.

cvs -d :pserver:anonymous@cvs.phpinsider.com:/export/CVS login
cvs -d :pserver:anonymous@cvs.phpinsider.com:/export/CVS checkout SmartyValidate

There is no password, just hit return when prompted for one.
Back to top
View user's profile Send private message Visit poster's website
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Fri Jun 11, 2004 6:53 am    Post subject: Reply with quote

[quote="mohrt"]
xces wrote:

You should always HTML escape variables that are in form text input or text areas. That way special chars won't screw it up.


Yeah i edited my reply allready i've seen it myself yesterday. But is it also needed to escape textareas?
Back to top
View user's profile Send private message
electr0n
Smarty Rookie


Joined: 26 Mar 2004
Posts: 32
Location: Germany

PostPosted: Fri Jun 11, 2004 1:40 pm    Post subject: Reply with quote

I've got a question, is the removing of the non validated variables built in now?
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Jun 11, 2004 1:50 pm    Post subject: Reply with quote

xces wrote:

Yeah i edited my reply allready i've seen it myself yesterday. But is it also needed to escape textareas?


Yes. Try putting </textarea> in the body of your text, see what happens.
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: Fri Jun 11, 2004 1:50 pm    Post subject: Reply with quote

electr0n wrote:
I've got a question, is the removing of the non validated variables built in now?


Nothing yet.
Back to top
View user's profile Send private message Visit poster's website
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Sat Jun 12, 2004 11:29 am    Post subject: Reply with quote

For people who have never used a CVS as a command line tool (like me) go to this site:
https://ccvs.cvshome.org/servlets/ProjectDocumentList?folderID=83&expandFolder=83&folderID=80

And download any stable version. Site is a bit slow, anyway you will get a warning when you first run the command that mohrte has written because you don't have an access file yet. Just ignore it or run it again (like i did) and you won't get an error. Next you can run the update cmd to download the CVS version.

I used "cvs-1-11-14.zip" as my CVS client.
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
Goto page Previous  1, 2, 3, 4, 5, 6 ... 16, 17, 18  Next
Page 5 of 18

 
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