Darby Felton schrieb:
We do not yet have a component that provides full functionality for
working with forms; this is a large undertaking, and there are a couple
of proposals for such:
Zend_Form - Simon Mundy & Ralf Eggert
http://framework.zend.com/wiki/x/DA4
Zend_Form_Controller Proposal - Simon Mundy
http://framework.zend.com/wiki/x/mQE
I don't think that form validation and the actual form definition should
be too deeply tied together. You shouldn't need to have to use a
fully-featured form package supporting building of the actual form
fields to use data validation for form-like data arrays.
Having said that, I think Zend_Validate is the right place to do
validation of data coming from forms, and when a form package is in a
developed-enough state to be actually useable, it should make use of
Zend_Validate.
It must however also be possible to build forms by hand (markup or
helpers in Zend_View templates) and define rules for validating incoming
data from these forms.
This is why the proposed functionality is needed.
I have seen suggestions similar to this before. How would this support
multidimensional arrays? For example, assume that you need to validate
an array where:
$aData['favorites']['colors'] = array('red', 'blue');
Good point - I suppose this could be done by nesting Zend_Validate
objects. In other words: Define a separate ruleset for each possible
nesting level in a new instance of Zend_Validate and pass that instance
to addValidator() in the main Zend_Validate object.
Yes, though I think there is some confusion over the Zend_Validate
component. It alone is not intended to solve the problem of form
validation. It is intended to solve the problem of validating a single
value against possibly multiple criteria. Zend_Validate would provide
the foundation, however, on which to build a component that eases the
pain of working with form data.
In that case, I think it may be a good option to provide a specialized
subclass of Zend_Validate to deal with array data, which could
optionally be used by a Zend_Form component.
CU
Markus