ZF-3819: Ids not updating in cloned sub forms


When cloning a single sub form to attach repeatedly in Zend_Form, the names update, but the ids do not. As an example:

$subForm = new Zend_Form_SubForm();
$subForm->addElement('text', 'foo');

$form = new Zend_Form(array('action' => '/foo/bar', 'method' => 'post'));

for ($i = 1; $i < 4; ++$i) {
    $name = 'sub' . $i;
    $sub  = clone $subForm;
    $form->addSubForm($sub, $name);

echo $form->render(new Zend_View);

This will result in the output:


As can be seen, the names are correct, but the ids are not.


The issue was that cloning was not cloning the elements, display groups, or sub forms. This is now resolved in trunk and 1.6 release branch.

Updating for the 1.6.0 release.