Skip to content

upload_file.rst: Recommend view transformer instead of manually "transforming" the property? #11158

Closed
@ThomasLandauer

Description

@ThomasLandauer

On https://symfony.com/doc/current/controller/upload_file.html in the 4th code block it says:

// updates the 'brochure' property to store the PDF file name
// instead of its contents
$product->setBrochure($fileName);

But the "second part" is not documented: If the file is already present, you also have to do this before creating the form:

$product->setBrochure(new File($product->getFileName()));

So the general question is: Wouldn't it be better to recommend a Data Transformer instead of manually transforming back and forth in the controller?

This would (would it?) also solve this problem with EasyAdmin: EasyCorp/EasyAdminBundle#2356

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