-- D M <[email protected]> wrote
(on Monday, 19 January 2009, 01:19 AM -0500):
> I'm writing to anyone who uses custom validators with Zend_Form that
> make use of $context to access other form elements.
> 
> As expected, when using custom validators with Zend_Form, the $value
> parameter supplied to the isValid function is filtered using the
> element's filter chain. Unexpectedly, the rest of the form elements
> accessible via the $context parameter are *not* filtered using their
> respective filter chains.
> 
> Since the $value supplied to isValid is filtered wouldn't it make
> sense to have the $context items filtered as well?

Yes and no; you may want to compare against a raw value. As it is, it
would be _incredibly_ difficult to make this happen, as the validators
must work both inside _and_ outside a Zend_Form context (i.e., they
could also be used with Zend_Filter_Input, in a custom validator chain,
or standalone). Additionally, there may be values not handled by your
form that could still be part of the context.

While it could be done, I'm not sure if there's a clean way to do it
that would be flexible enough to also address some of the above items.

> Perhaps this can be mentioned in the docs and/or changed in future
> versions. It really took me for a spin. Thoughts anyone?

-- 
Matthew Weier O'Phinney
Software Architect       | [email protected]
Zend Framework           | http://framework.zend.com/

Reply via email to