Hello, I am having some trouble with Zend_Form and display groups (ZF 1.8.2). I want to add an existing form element to an existing display group within the same form, but when I call $displayGroup->addElement($element), the element is re-added to the form, causing it to be rendered twice (once in the display group, and again outside of the display group).
Here is my code (trimmed for clarity): class MyForm extends Zend_Form { public function init() { /* ... */ } public function addStandard(Standard $standard) { $name = 'standard_' . $standard->getId(); $this->addElement('checkbox', $name); $displayGroup = $this->getDisplayGroup('standards'); $displayGroup->addElement($this->getElement($name)); } } I have also tried just specifying the element's name, but that ends up in a fatal error: Call to a member function getName() on a non-object in > /usr/share/pear/Zend/Form/DisplayGroup.php on line 433 I also noticed that I cannot create a display group without adding elements to it: $this->addDisplayGroup(array(), 'standards'); // throws exception "No valid elements specified for display group" This makes it difficult to create empty display groups as containers for the elements to be added later. I can get around this by creating the display group automatically when the first "standard" is added, but I am stumped on how to add the next standard to the existing display group. -- Hector