-- lightflowmark <[email protected]> wrote (on Wednesday, 11 February 2009, 08:44 AM -0800): > > > > > Actually, it needs to be documented better. The idea is that it > > validates against *only* those items that are passed to it -- and not > > *all* elements in the form (which is the behavior of isValid()). If an > > element passed to isValidPartial() has specified that it is required, > > then isValidPartial() will merrily check to see if a non-empty value was > > provided. > > > > I'm not sure I see the point of it, then, certainly in a POST environment > (which will return all values of the form, some as empty strings). If I > know which values I am expecting to be present, then I could trivially loop > through them and do something like > $form->getElement('expectedName')->isValid($value); if I don't know which > values I'm getting, isValidPartial is no help because if I pass the form the > whole POST array, it validates everything. > > When should I use isValidPartial? I'm sure I saw it in the ZFiA book in an > Ajax context, but is it useful elsewhere?
It's actually primarily useful for Ajax validation, where you often want to submit one or a small subset of elements to validate prior to submitting the entire form. (And this was the specific use case for which it was designed.) -- Matthew Weier O'Phinney Software Architect | [email protected] Zend Framework | http://framework.zend.com/
