Skip to content

Removing all files after updating VichFileType collection - Doctrine ODM calls postRemove event #844

Open
@velkony

Description

@velkony

Hello,
I would like to use collection of VichFileType.
For this purpose, I have the following settings:

MainType.php :

->add('moreFields', CollectionType::class, array(
                'label' => false,
                'required' => false,
                'entry_type' => FileDocumentType::class,
                'prototype' => true,
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false
            ))

FileDocumentType.php:

$builder->add('imageFile', VichFileType::class, [
            'required' => false,
            'allow_delete' => true
        ])

vich_uploader.yaml

vich_uploader:
    db_driver: mongodb
    mappings:
        settings_image:
            uri_prefix: /
            upload_destination: '%kernel.project_dir%/public/uploads/images'
            inject_on_load: false
            delete_on_update: true
            delete_on_remove: true

After updating the form, without touching the collection, I find out that the files are deleted.
How can I solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions