ZF-2754: Rendering a form after clearElements() has been called raises an exception

Description

Reproduce code:


$form = new Zend_Form();
$form->addElements(array(
    'username' => 'text',
    'password' => 'text',
));
$form->clearElements();
echo $form;

Expected: XHTML form with no content.

Actual:


PHP Warning:  Corruption detected in form; invalid key found in internal iterator in .../framework/library/Zend/Form.php on line 2125

Comments

calling $form->clearDisplayGroups() causes the same exception.

Fixed in trunk and 1.5 release branch