I'm new to symfony and trying to make sure I do everything the correct
way.

What I want to do is check to see what country a user selected during
signup.  If they selected the US, I want to verify that their postal
code is a 5 digit number.  I figure the best way to do this is to use
sfValidatorPass on the postal code field during validation.  Then in
the postValidator I will use sfValidatorCallBack to call a method of
the form class.  This method will perform the logic checks.  If
validation fails I will then execute something like the following.  Is
this a good way to go or is my approach wrong?

$validator->addMessage(
    'invalid_postal_code',
    'Please enter a valid 5 digit postal code'
);

throw new sfValidatorErrorSchema(
    $validator,
    array(
        'postal_code' =>  new sfValidatorError(
            $validator,
            'invalid_postal_code',
            array()
        )
    )
);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to