symfony2admingenerator / AvocodeFormExtensionsBundle

(old-legacy) Symfony2 form extensions for Admingenerator project (also working standalone!)
Other
48 stars 31 forks source link

Problem when using single_upload in collection #54

Closed montabou closed 11 years ago

montabou commented 11 years ago

I was using file type in collection and everything works (I can add, edit, delete). If I replace formType from file to single_upload I can edit and delete, but I can not add a new file. I've got :

Catchable Fatal Error: Argument 1 passed to ...\SiteBundle\Entity\Data::addFile() must be an instance of ...\SiteBundle\Entity\File, null given in /.../.../SiteBundle/Entity/Data.php line ...

I don't know if this is an excepted behavior.

I've looked into the POST request when I try to add a file and the input file form name change. For file type:

edit_data[files][2][file]

and for single_upload type:

edit_data[files][2][file][file]

Here is an extract from Data-generator.yml and File-generator.yml:

fields:
        files:
            label: data.files.label
            dbType: collection
            formType: collection
            addFormOptions:
                type: \...\AdminBundle\Form\Type\File\EditType
                allow_add: true
                allow_delete: true
                by_reference: false
               options:
                    data_class: ...\SiteBundle\Entity\File

and

fields:
        file:
            label: file.file.label
            dbType: string
            formType: single_upload

If I change single_upload by file in my File-generator.yml everything works fine...

ioleo commented 11 years ago

@montabou I've not tested collection of single uploads. Does your fix (merged) resolve this issue?

montabou commented 11 years ago

Yes it does :-) Thanks