Editing forms with live_file_input
Imagine you are writing an app to handle products for a marketplace. Each Product has up to 3 images associated with it. When editing a Product, you should be able to remove any of the already associated images and add new images to the Product, alwa...
blog.miguelcoba.com16 min read
For anyone who is looking for a way to change the
:uploadsassigns to set themax_entriesproperty, we can useMap.putto update the entire assigns socket onmaybe_update_upload_config/2, something like this:defp maybe_update_upload_config(socket, max_entries) do config = Map.get(socket.assigns.uploads, :images) new_uploads = Map.put(socket.assigns.uploads, :images, %{config | max_entries: max_entries}) new_assign = Map.put(socket.assigns, :uploads, new_uploads) Map.put(socket, :assigns, new_assign) end