Skip to content

[Upload File]: Doctrine Listener vs. view transformer for File<=>String conversion #11390

Closed
@ThomasLandauer

Description

@ThomasLandauer

Is a Doctrine Listener preferred over a view transformer to switch between the File instance and the string? I'm wondering, since the error message recommends a view transformer:

The form's view data is expected to be an instance of class Symfony\Component\HttpFoundation\File\File, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Symfony\Component\HttpFoundation\File\File.

...whereas on https://symfony.com/doc/current/controller/upload_file.html a view transformer isn't even mentioned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions