-- SiCo007 <[EMAIL PROTECTED]> wrote
(on Tuesday, 19 February 2008, 05:17 AM -0800):
> I would like to add this ability to non Zend Form validators and am
> interested how Zend_Form goes about passing the context to the validators.

Very easy: it simply passes the value being tested as $value, and then
the full array of values being validated by the form as $context.

In Zend_Form::isValid() (and isValidPartial()), we iterate over the
various elements and sub forms, and call:

    $item->isValid($value, $data)

Then, within Zend_Form_Element, we loop over each validator, and simply
call:

    $validator->isValid($value, $data)

Zend_Validate_Interface defines isValid($value), but PHP allows you to
specify *additional* arguments in concrete implementations, which is why
this is possible in Zend_Form.

> Have you subclassed Zend_Filter_Input or is there another method?

Zend_Filter_Input is not used by Zend_Form; Zend_Form uses
Zend_Validate_* and Zend_Filter_* directly. 

ZFI is for evaluating many elements at once, while Zend_Form places the
actual validation and filter chains with the *individual* elements --
which allows for re-use of elements in different forms. As such, the
design of ZFI does not really suit Zend_Form, though they share some
similar capabilities.

> Or has Zend_Filter_Input been changed in 1.5?

The only changes to ZFI that I'm aware of are:

  * Now uses Zend_Loader_PluginLoader for loading validators and filters
    (which allows developers to create their own implementations of
    standard validators and filters)

  * Addition of I18N capabilities (via Zend_Validate_Abstract)

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to