Hi Matthew,

>> [...]
>> $newPersonSubForm=new Zend_Form_SubForm(array(
>>     'legend' => 'Neue Person',
>>     'disableLoadDefaultDecorators' => true,
>>     'disableTranslator' => true,
>>     'decorators' => array(
>>         'FormElements',
>>          array('HtmlTag', array('tag' => 'ol')),
>>             'Fieldset')));
>> $editForm=new Club_Person_Form_Edit();
>> $editForm->removeDisplayGroup('buttons');
>> $newPersonSubForm->addSubForm($editForm, 'newPerson-subform');
>> $this->addSubForm($newPersonSubForm, 'newPerson');
>> 
>> This works as expected: I get my normal form fields and then I get a
>> fieldset named 'fieldset-newPerson' from the Zend_Form_Subform under
which I
>> get all my elemts from Club_Person_Form_Edit in array notation e.g.
>> 'newPerson[firstName]'.
>> 
>> The problem is, that the line 
>> $editForm->removeDisplayGroup('buttons');

>Well, the prolem is that you added a _sub form_, not a display group.
>Try using removeSubForm(). However, if you do that, you lose all
>elements beneath it.

Not really, I add $editForm, which is a Club_Person_Form_Edit (extended
Zend_Form) wrapped in $newPersonSubForm, a  Zend_Form_Subform, to my form.
But inside Club_Person_Form_Edit I have a display group 'buttons' which
contains save and reset button. I want to remove this display group from
$editForm to avoid to save buttons being rendered. 
I already managed to get this working by removing each item inside the
display group separately which is quite logical if I think about it because
a display group just groups items visually and is not an element container
itself (as for example a Zend_Form_Subfrom).

>> does not work as expected. My 'Save' button is grouped in a display-group
>> 'buttons' in Club_Person_Form_Edit, so I thought that I could remove
those
>> buttons just by removing the display group to avoid two 'Save' buttons
being
>> rendered.
>> 
>> What am I doing wrong and is this a best practice at all??? Do I have to
>> remove the elements inside the display-group one by one?
>> And is there a way to avoid this 'hack' of creating a Zend_Form_SubForm
and
>> add the real form as a subform of this subform and still get the desired
>> result (array notation of all elements in Club_Person_Form_Edit)?

The other question still is: What's the best practice to include one form
into another having the included form namespaced somehow (array-notation)?
Is it the right way to wrap the desired form into a Zend_Form_Subform or is
there another way, e.g. using setElementBelongsTo() or something like that.
And then another question arises... If I do the form inclusion like I
described above, all form elements get namespaced correctly (array notation)
but the generated fieldset-ids remain untouched which could cause duplicate
ids inside to page. Is there a way to give those fieldsets a namespace?
I hope it's understandable what I'm trying to do ;-)

Best regards

Stefan


Reply via email to