Is there a way to control the failure messages of the Dropzone component?

Currently, it seems to be set up to display 'Only a single file may be uploaded at a time' for any type of error. However, the same message appears even when the file type is incorrect. I would like to do one of two things: either change the message depending on the type of error or use a more general message that covers errors broadly instead of being too specific. How can I achieve this?

Hello @micapareddes!

I'm not sure if you can change the error response in your screen shot, but you could toy around with some alternative methods of delivering the message. Something like disabling queries/components if your conditions aren't met and then showing an in app tooltip/text block with what is wrong.

For the file type issue, is the component letting users place files that don't match your file type criteria?

Hi @micapareddes,

You can definitely set up a custom error message using 'Validations Rules' and setting up a custom role using some Javascript!

Here is an example, where I key into fileDropzone1.value at index zero to grab the first file that has been added, then I grab the .type and use a ternary to check if the string is of a file type that I do not want user to upload.

If the file is the wrong type, the code block should return a string, this will be an error message, in my example the error message is the string 'images/png not allowed'.

If you have multiple file types that you want custom error names for, you could replace the ternary Javascript logic with a chain of "if, else" Javscript logic.

Also you can inverse the logic if you only want to allow a single file type, where you can say if .type !=== ''file type I want and then have the return string be 'please provide x file type'.

1 Like