ZF-11860: Zend_Form -> Zend_Form_SubForm -> Zend_Form_Element::setBelongsTo - Zend_Form loses one array notation if element in subform belongs to an array


I came across an annoying bug in Zend Framework and have been trying to find an answer through several forums.

The problem is that when I have a form and add a subform in it and add subform into that form and then add an element into the last subform which belongs to an array; Zend_Form loses one array from the middle.

$form = new Zend_Form();

$subForm1 = new Zend_Form_SubForm();

$subForm2 = new Zend_Form_SubForm();

$element = new \Zend_Form_Element_Text('textElement');


$subForm1->addSubForm($subForm2, 'subForm2');
$form->addSubForm($subForm1, 'subForm1');

echo $form->render();

If this is intentional it's totally wrong in my opinion; If elements in the subform belong to an array it doesn't mean that an element could not belong to some array itself and the elements array would then belong to the subforms belongsto array.


Code tags added.