-- Katulus <[EMAIL PROTECTED]> wrote
(on Tuesday, 08 April 2008, 01:44 PM -0700):
> I use display groups to create "containers" with id attributes to
> manipulate them in javascript and I would really appreciate ability to
> nest display groups.
>
> I tried something like this (elemX is any form element):
> $form->addDisplayGroup(array('elem1','elem2'), 'group1',
> array('id'=>'group1'));
> $form->addDisplayGroup(array('group1','elem3'), 'group2',
> array('id'=>'group2'));
>
> and want result like:
> <group2>
> <group1>
> <elem1><elem2>
> </group1>
> <elem3>
> </group2>
>
> but I just get error "No valid elements specified for display group".
>
> Is there a way to achieve this effect with current Zend_Form? I know
> that I can simulate this by using nested sub-forms, but sub-forms are
> handled differently and working with them in this way is quite
> uncomfortable, because for example you have to set decorators for
> their elements individually.
The short answer is: if you want nesting, use the object that allows for
it: a sub form.
Sub forms are just like regular forms, except for the class name, the
default decorators, and one or two items of metadata. I have no idea
what you mean by "you have to set decorators for their elements
individually"; you can call setElementDecorators() just as easily on a
sub form as on a regular form.
Display groups are intended simply for grouping *elements* in a form --
not sub forms or other groups. The grouping is for cosmetic purposes
only -- hence the term 'display'. The elements in them actually belong
to the parent form, so having them namespaced differently is outside
their scope -- but well within the scope of sub forms (which are
intended for this kind of logical grouping).
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/