« Return to Thread: Zend_Form: Subform Validation

Re: Zend_Form: Subform Validation

by Steven-81 :: Rate this Message:

Reply to Author | View in Thread

>> Although this is only my first attempt at using Zend_Form maybe future
>> releases would benefit from some kind of mechanism for grouping fields
>> together with a particular mind to validation? Almost like extending
>> the display group functionality?
>
> Extending the "sub form" functionality makes more sense, as they are
> supposed to be used for logical groupings (validation falls under this
> category).
>
> Unfortunately, I have yet to see a use case that can be generalized for
> this; in most cases, extending Zend_Form_SubForm and overriding
> isValid() appears to make the most sense, as it allows the developer to
> customize for the form's particular needs. I am, however, open to adding
> such capability if the community can present a good, common use case.

Mathew,

Yeah I guess a subform is the correct construct when you consider it a
logical grouping of elements, maybe adding additional error message
functionality rather than relying on setDescription() is appropriate?

My use case relates to taking a date as input, I elected to use 3
fields to capture the elements, obviously all 3 fields require
consideration to establish a valid date (in my instance I was
validating that the date was within a boundry also). I elected to go
with a subform rather than using the $context paramater to validate as
that felt too much like a kludge and the error message would relate to
a specific field rather than a group of fields. As another example,
maybe 2 fields detailing colour and size of clothes, individually the
fields may contain valid data, however it is the combinations that
need to be able to generate out of stock messages.

Incidently, is there a convenience method to reset a form once it's
been populated?

Steve

 « Return to Thread: Zend_Form: Subform Validation