I wrote a post on my blog the other day that does exactly this:
http://cogo.wordpress.com/2008/04/16/custom-validators-for-zend_form_element/
Xavier Vidal Piera wrote:
Hi
I'd like to know which is the best approach to build complex forms with
Zend_Form.
As a example, in a "Register User" form we can find the typical "enter
your password" input twice, so when we declare the form in our
controller we can do two things:
1. add two "Zend_Form_Element_Password" and add validators to both
elements (setrequired, stringlength,...)
or
2. build a new Form_Element called "DoublePassword" where in his
"isValid" method we can setup the logic to test if both values are equal
with a custom validator (and mantain other possible assigned validators).
At the moment, is there any method or proposal to test values between
Form_Elements (like the "equals" between passwords)?.
I've find quite useful to build custom elements to achieve certain
functionalities but i don't like to write a lot of them if there is a
way to connect elements between them at the validation moment.
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://web.xaviervidal.net
610.68.41.78
--
Christer Edvartsen
[EMAIL PROTECTED]
http://cogo.wordpress.com/