Adding Titles to Image Uploads

Hey there,

I’m trying to add titles to the images being uploaded using the uploads guide.

After tinkering a bit, I asked our beloved AI tools. What they suggest is maintaining a separate metadata map and creating the necessary structure by using a metadata[#{entry.uuid}][title] input name. So something along the following lines:

...
<.live_file_input upload={@uploads.image} />
        <section phx-drop-target={@uploads.image.ref}>
          <%!-- render each image entry --%>
          <article :for={entry <- @uploads.image.entries} class="upload-entry">
            <figure>
              <.live_img_preview entry={entry} />
              <figcaption>{entry.client_name}</figcaption>
            </figure>
            
            <%!-- extra input to add an image title --%>
            <.input
              name={"metadata[#{entry.uuid}][title]"}
              type="text"
              label="Titel"
              value={get_image_metadata(@image_metadata, entry.ref, :description)}
              phx-change="update-image-metadata"
            />
...

While this should work, it just feels a little hacky to render this input so raw and manual.

Is there a cleaner approach, where I can eg. lean more on the Phoenix.HTML.FormField abstraction and use <.input field={@image_form[entry.uuid][:title]} ... or similar?

Thanks :slight_smile: