|
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 |
Spookyfish Smarty Rookie
Joined: 18 Mar 2005 Posts: 8
|
Posted: Wed Apr 06, 2005 2:21 pm Post subject: SmartyValidate: multiple criteria for one form field bug? |
|
|
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 |
|
Spookyfish Smarty Rookie
Joined: 18 Mar 2005 Posts: 8
|
Posted: Thu Apr 07, 2005 10:16 am Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Apr 07, 2005 2:04 pm Post subject: |
|
|
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 |
|
Spookyfish Smarty Rookie
Joined: 18 Mar 2005 Posts: 8
|
Posted: Thu Apr 07, 2005 2:23 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Apr 07, 2005 3:05 pm Post subject: |
|
|
Be sure you register your form before registering validators:
Code: | SmartyValidate::register_form('myform');
SmartyValidate::register_validator(...,'myform'); |
|
|
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
|