Anyone have a live upload example with a simple table association?

I’ve been looking for a very simple live upload example where it’s like a simple product table and you can upload multiple images when you create that product. You can also edit that product, and on the edit form you can change the fields as well as the images associated with that product.

product:
title
description
price
image_urls (string array)

I couldn’t find anything like this so I figured I would ask. It seems like everybody would benefit from an example like this.

If there are none, I will write one once I figure this out, it’s still a little greek to me.

I did find something similar: live_upload_example/multi_input_uploads_live.ex at main · mcrumm/live_upload_example · GitHub - but the problem is that it doesn’t associate the images to a schema and that’s specifically what I’m looking for.

Hmm, you’d probably want to manually use Ecto.Changeset.put_change/3 to add the image_urls to the changeset since, as far as I know, there aren’t form inputs that just work with lists and maps.

So going off of the multi_input_upload example you referenced, when you handle the multi input uploads complete, you could add it nested under your changeset instead.

Alternatively, you could keep the paths at the top level of the socket assigns and add it to your changeset when handling the save event for the form.