 |
 |
SmartyValidate: Error is reported when there is no error
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
PHP file:
Code:
SmartyValidate::register_validator('pass1_len','password1:4:16','isLength',false,false,'trim');
SmartyValidate::register_validator('pass_equ','password1:password2','isEqual',false,false,'trim');
Template:
Code:
{validate id="pass1_len" message="Password must be between 4 and 16 characters."}
{validate id="pass_equ" message="Passwords do not match."}
The problem is that if the first check fails, the second check triggers an error, *even* if they really are equal, but just under 4 characters in length. I can't use halt, because I have other validators that need to print after it, regardless. If I enter 4 characters into both fields, the equal error disappears.
My question is why does a validator trigger an error if it's a second validator and correct? I tried this with other validator criteria, and even my own criteria, and it always does the same thing. How do I get around it without halt? I shouldn't even have to use halt, because the error shouldn't have been triggered.
Also, if I submit a page with no data, both errors are shown. then i enter a valid pass in, both errors disappear, and if i delete the passwords and submit again, it works properly - only the password length error is shown.
With Smarty debugging on, it shows the right errors. It doesn't show the errors that shouldn't be shown, but are anyways:
Code:
{$desiredusername} empty
{$emailaddress} empty
{$errors} Array (5)
desiredusername => Username must be between 2 and 16 cha...
password1 => Password must be between 4 and 16 cha...
firstname => First name must be between 2 and 16 c...
lastname => Last name must be between 2 and 16 ch...
emailaddress => Not a valid email address.
{$firstname} empty
{$lastname} empty
{$password1} empty
{$password2} empty
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
I haven't seen those for Smarty before - are they add-ons you found somewhere?
From personal experience, I find it extremely reliable to use the PEAR QuickForm libraries to generate and validate forms, then use the Smarty Renderer to pass an array of data for Smarty to simply display, rather than parse.
http://pear.php.net/
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
No, isLength, and isEqual come with SmartyValidate.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|