Issues

ZF-10679: Form ID overrides Fieldset ID and causes dupe IDs

Description

This code:


$form1 = new Zend_Form();
$form1->setDecorators(
    array(
        'FormElements',
         array('Fieldset', array('legend' => '',
                'id' => 'fieldset-id')),
        'Form',
    )
);
$this->view->form1 = $form1;

produces this form:




While this code:


$form2 = new Zend_Form();
$form2->setDecorators(
    array(
        'FormElements',
        array('Fieldset', array('legend' => '',
                'id' => 'fieldset-id')),
        'Form',
    )
);
$form2->setAttrib('id', 'form2-id');
$this->view->form2 = $form2;

Produces this form:




Note the duplicate ID between the form and the fieldset. In Zend_Form_Decorator_Fieldset::getOptions() the ID of the form is added to the options for the fieldset element. Then in render(), because the fieldset has an ID attribute that attribute is not modified.

Expected behavior:

Form ID should not override fieldset ID and the two IDs should not match.

Comments

Thanks for the simple test case. Patch with unit test to resolve issue is attached.

Applied to trunk in r23425, 1.11 release branch in r23426