benlime
1
Okay, so maybe I am a little tired, but I can’t figure this out right now. The solution probably is simple ![:smiley: :smiley:](https://elixirforum.com/images/emoji/apple/smiley.png?v=12)
Is there any way to show the errors retrieved from upload_errors/2
when using LiveView Uploads in a flash message?
The link I am missing right now is, where can I call put_flash
when an upload got errors?
benlime
2
Nevermind. The obvious solution is to extract the errors in the validation event and call put_flash
there. ![:man_facepalming: :man_facepalming:](https://elixirforum.com/images/emoji/apple/man_facepalming.png?v=12)
def handle_event("validate_upload", params, socket) do
errors =
for entry <- socket.assigns.uploads.editor_images.entries,
err <- upload_errors(socket.assigns.uploads.editor_images, entry),
do: error_to_string(err)
socket = put_flash(socket, :error, Enum.join(errors, ", "))
{:noreply, socket}
end