Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying the error message for disallowed mimeTypes #12

Closed
darinda opened this issue Jan 15, 2019 · 7 comments
Closed

Allow specifying the error message for disallowed mimeTypes #12

darinda opened this issue Jan 15, 2019 · 7 comments

Comments

@darinda
Copy link
Contributor

darinda commented Jan 15, 2019

Symfony allows for specifying the error message that will be shown when the user selects a file of a mime type that is disallowed (https://symfony.com/doc/current/reference/constraints/File.html#mimetypesmessage)

It would be nice to be able to define that error message on content type level in the admin interface.

@darinda
Copy link
Contributor Author

darinda commented Jan 15, 2019

@MarioBlazek
Copy link
Contributor

@darinda, please create PR based on the code from your fork. Just one notice, maybe a better solution would be to use mimeTypeMessage from translation file rather than saving/reading it from the database.

@darinda
Copy link
Contributor Author

darinda commented Jan 16, 2019

@MarioBlazek PR has been created. I moved the mimeTypeMessage to the database because it can be translated there. ContentTypes can be translated, so i think this is the correct place to put them.

That way the mimeTypeMessage can be specified like "Please upload only PDF documents!" instead of having the standard symfony message stating something about the mime types which a normal end user won't be able to understand.

@emodric
Copy link
Member

emodric commented Jan 17, 2019

Hm, that might make sense. What happens if we leave it to an empty value?

@darinda
Copy link
Contributor Author

darinda commented Jan 17, 2019

What happens if we leave it to an empty value?

Then symfony's default error message will be displayed, as it was before this pull request.

So The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.

@darinda darinda closed this as completed Jan 17, 2019
@darinda darinda reopened this Jan 17, 2019
@darinda
Copy link
Contributor Author

darinda commented Jan 25, 2019

@emodric bump ;)

@emodric
Copy link
Member

emodric commented Jan 28, 2019

I've left a couple of comments on #13.

Otherwise, if everything works, I'm +1 for merging.

@MarioBlazek What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants