1
votes

A have a simple custom form type how add (with the FormBuilderInterface) a upload field of type FileType.

When i try to upload a file greater than the php upload_max_filesize. I got this default message :

https://github.com/symfony/symfony/blob/4.3/src/Symfony/Component/Form/Extension/Core/Type/FileType.php#L150

My purpose is to translate it. It seems I need to pass a translator to the FileType but I don't know how to do it.

1
I have open a related github issue: github.com/symfony/symfony/issues/32045COil

1 Answers

1
votes

This is a bug in Symfony. We forgot to add back the form.type tag when updating the service config to pass a translator. This will be fixed in the next patch releases (see https://github.com/symfony/symfony/pull/32116).

In the meantime, you should be able to register the FileType as a service yourself (for example, in your config/services.yaml file) like this:

# config/services.yaml
app.file_type:
    class: Symfony\Component\Form\Extension\Core\Type\FileType
    tags: [form.type]