I was wondering if anyone has encountered recent trouble rendering errors for the max_entries
constraint with Phoenix Live View live uploads?
I am noticing that the max_file_size
constraint renders errors as expected, but the max_entries
only renders an error once with the overarching @uploads.your_config_name.errors
. For instance, it does not render any errors using the upload_errors/2
function.
For instance:
# max_entries: 2
<%= for entry <- @uploads.your_config_name.entries do %>
<%= for err <- upload_errors(@uploads.your_config_name, entry) do %>
<%= humanize(err) %>
<% end %>
<% end %>
This is not returning any errors when trying to upload more than the allotted max_entries
constraint. However, it will return the :too_large
error if any of the uploads are over the max_file_size
constraint.
I am able to return the :too_many_files
error once, rather than for each file (as is the case with the max_file_size
constraint), when making a standalone call to @uploads.your_config_name.errors
:
<%= for {_ref, error} <- @uploads.your_config_name.errors do %>
<%= humanize(err) %>
<% end %>
This will return the :too_many_files
error once, but never more than that. Whereas it will return the :too_large
error per file that is over the max_file_size
constraint.
Update
I am noticing the following returns for the {_ref, error}
above:
# max_file_size
{"4", :too_large}
# max_entries
{"phx-FnJzgHSa0PgcUgIF", :too_many_files}
This is where I think my issue is.
Update 2
I just went with a workaround where I don’t render the :too_many_files
error with each file, but rather render the error just once.
Update 3
I now realize that this is the expected behavior. I’ve updated the title as the behavior is correct. I’m sorry!
I am using Phoenix Live View 0.15.4, Phoenix 1.5.8, and Elixir 1.11.4-otp-23.
Thank you