Issues

ZF-5835: Zend_form_element_file has wrong name when is nested in subform

Description

I have found bug in File element. when I put file element into subform, then it doesn't have proper name.

Code snipet:

 
        $filesForm = new Zend_Form_SubForm();

        for ($h1=1;$h1<=5;$h1++) {
            $subForm = new Zend_Form_SubForm();
            $subForm->addElement('text', 'name', array(

            'filters'    => array('StringTrim' ),
            'validators'  => array('NotEmpty'),
            'label'      => 'Název ' ,
                    ));

            }

            $subForm->addElement('file', 'file', array(
            'filters'    => array('StringTrim', ),
            'label'      => 'Obrázek',
            'validators' => array (array('Size', false, 5*1024*1024),
                        array('Extension', false, 'jpg,png,gif'),
                        array('Count',false,1)),
                ));

            $filesForm->addSubForm($subForm,$h1);
        }

        $this->addSubForm($filesForm,'new_files');

...

then text elements have the proper names like : new_files[1][name] , so should file element, bu it is still named only file instead of new_files[1][file]

View script produces code like :

 Název  


Obrázek

label of File Element is properly set, but its id and name doesn't contain parent arrays.

I have found that 1.7.5 should have support for FileElement in subforms, but there is still this issue.

    

Comments

I have probably discovered solution :

In Zend_Form_Decorator_File in the version 1.7.5, there is

$name = $element->getName();

on line 91

and there probably should be

$name = $element->getFullyQualifiedName();

Also for right id line 94

should be -

$attribs['id'] = $element->getId();

instead of original

$attribs['id'] = $name;;

Closed as duplicate of ZF-5864. Read manual, FAQ and ZF-5864 for details.