Misleading documentation for Uploads in Phoenix Live View guide

Hello there!

I would like to address a misleading documentation of Uploads tab of Phoenix Live View guide.

Documentation says that @uploads are available at the view in which you used in mount

allow_upload(socket, :logo, accept: ~w(.jpg .jpeg .png), max_entries: 1)

This is fine, but when rendering a form using ModalComponent using helper function live_modal, it do not use the socket.assigns anymore. (code created with mix phx.gen.live)

AppWeb.LiveHelpers.live_modal(socket, component, opts)

which calls

  # TODO: Deprecate the socket as argument
  defmacro live_component(_socket, component, assigns \\ [], do_block \\ []) do ...

Yes, it turns out socket is not used inside and you need to pass all necessary assigns as a separate argument. Took me around 1.5 hours to understand this.code

I would like to update the documentation of Update page of Phoenix Live View guide, how should I do this?

1 Like

All documentation is part of the phoenix_live_view github project, just like all other Elixir code: GitHub - phoenixframework/phoenix_live_view: Rich, real-time user experiences with server-rendered HTML. Definitely a good catch!

Its been brought up before but Uploads don’t work right now with live_components, so adding one in the live_modal isn’t going to work.

1 Like

They actually do work with LiveComponent since pull #1223 (Nov 2020).