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: multiple criteria for one form field bug?

 
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
Spookyfish
Smarty Rookie


Joined: 18 Mar 2005
Posts: 8

PostPosted: Wed Apr 06, 2005 2:21 pm    Post subject: SmartyValidate: multiple criteria for one form field bug? Reply with quote

Is there a little bug when using two criteria on one form field?

I have in my controller:
Code:

      SmartyValidate::register_validator('domain_empty', 'domain', 'notEmpty', False, False, 'trim,lower,domain', SECTION);
      SmartyValidate::register_validator('domain_valid', 'domain', 'isValidDomain', False, False, NULL, SECTION);


In the template I have:
Code:

      {validate id="domain_empty" assign="domain_error" message="Domain is empty"}
      {validate id="domain_valid" assign="domain_error" message="Invalid domain"}


An is_valid() call will set $_failed_fields['domain'] when the domain is empty and when skip the domain_valid field when processing it.

So, the [valid] key does not exist for domain_valid. Then line 110 in function.validate.php gives a Notice: Undefined index: valid in

Code:

110:            if(!$_sess['validators'][$_validator_key]['valid']) {

_________________
Spookyfish
Back to top
View user's profile Send private message
Spookyfish
Smarty Rookie


Joined: 18 Mar 2005
Posts: 8

PostPosted: Thu Apr 07, 2005 10:16 am    Post subject: Reply with quote

Well, anyone?

For now, I've just changed the code by adding a @:

Code:

110:       if(!@$_sess['validators'][$_validator_key]['valid']) {

_________________
Spookyfish
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Apr 07, 2005 2:04 pm    Post subject: Reply with quote

You have to specify your form name if not using the default:

Code:
{validate form="myform" id="domain_empty" assign="domain_error" message="Domain is empty"}
{validate form="myform" id="domain_valid" assign="domain_error" message="Invalid domain"}


I have submitted some patches to CVS to fix the PHP notices.
Back to top
View user's profile Send private message Visit poster's website
Spookyfish
Smarty Rookie


Joined: 18 Mar 2005
Posts: 8

PostPosted: Thu Apr 07, 2005 2:23 pm    Post subject: Reply with quote

I was using {validate_init form="blah"} so that should've taken care of the non-defautl form name.

Thanks for the patch.
_________________
Spookyfish
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Apr 07, 2005 3:05 pm    Post subject: Reply with quote

Be sure you register your form before registering validators:

Code:
SmartyValidate::register_form('myform');
SmartyValidate::register_validator(...,'myform');
Back to top
View user's profile Send private message Visit poster's website
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