ZF-10387: function _addDisplayGroupObject has to remove elements from Zend_Form - else rendering the elements twice

Description

When you add an object of Zend_Form_DisplayGroup to the Zend_Form it will not remove the elements in Zend_Form. When rendering the form, it will render the elements twice. (in the decorator FormElements of Zend_Form and the in the decorator for the Zend_Form_DisplayGroup)

testcase: (it will render the element test twice)


$oForm = new Zend_Form();
$oForm->addElement('text','test');
        
$oDisplayGroup = new Zend_Form_DisplayGroup('bug',$oForm->getPLuginLoader('decorator'));
$oDisplayGroup->addElement($oForm->getElement('test'));
$oForm->addDisplayGroups(array($oDisplayGroup));
echo $oForm;

solution: add following code in _addDisplayGroupObject in Zend_Form (it will remove the elements from the ordering in Zend_Form, so they won't be rendered)


foreach ($group->getElements() as $element) {
    unset($this->_order[$element->getName()]);
}

Comments

Can you detail:

  • What are your expectations? In other words, when you perform X, you expect Y to happen.
  • What actually happens? In other words, when you perform X, you expect Y to happen, but instead Z happens.

Your report presents a solution, but it doesn't clearly state what the problem is. It's entirely possible that it's by design, but we cannot be certain until we have this information.

Thanks!

edited description with the real problem

I believe this issue relates to ZF-10958

Issue ZF-11729 is a duplicate of this and is resolved/fixed.