Zend Validate PostCode in a Zend Form -> Validate depending on given country
How can I validate a zipcode field in my form depending on the country set in the "country" field in the same form?
I somehow need to get access to the form instance or the value of another field. Is t开发者_JAVA技巧here a way to do this in a Callback validator?
Check out the "Validation Context" note on this page - http://framework.zend.com/manual/en/zend.form.elements.html (no direct link, just Ctrl+F Validation Context
)
You can use the $context
in a custom validator to access the rest of the submitted form data.
精彩评论