Using liveview form to send data back to controller

Thanks everyone for the ideas!

Main problem solved:

I was missing alot of knowledge. Now I see the problem was the field didn’t work as I thought, i.e. automatically. I ended up just going with html after all, since yes, the rest of the details are still on the socket.

<button class="btn btn-primary" phx-click={:alert} value={user.id}></button>

def handle_event("alert", values, socket) do
    IO.inspect(values) # %{"value" => "1"}

Secondary problem: Re: the input component:

I didn’t know I needed to implement <.input/> myself. I’ve tried using the example here but I get undefined function attr/2. Phoenix 1.6 I think.

So I’m trying this, but I don’t know where it goes. In it’s own file? How do I use it? Since there is no render.

def input(assigns) do
  ~H"""
  <input type="text" name={@field.name} id={@field.id} value={@field.value} class="..." />
  """
end