I’m quite new to Elixir and the Phoenix framework, so bear with me if I am doing something obvious wrong…
Using a Phoenix Liveview and the generic table
component provided by core_components.ex
I’m trying to send the ID of the row item as the phx-value-id
of the button
<:action>
<.button
type="button"
phx-click="toggle"
phx-value-id = "???" #this is the wrong place to do that
<span class="hidden sm:inline">Disable</span>
</.button>
<.button
type="button"
phx-click="delete"
phx-value-id = "???"
<span class="hidden sm:inline">Delete...</span>
</.button>
</:action>
I was able to add the phx-value-id
to the corresponding <span>
element by adding phx-value-id={"#{Phoenix.Param.to_param(row)}"}
to the :action
part of the table component
<span
:for={action <- @action}
phx-value-id={"#{Phoenix.Param.to_param(row)}"}
>
<%= render_slot(action, row) %>
</span>
I can think of how this can be done by using a for loop <%= for row <- @rows do %>
though I’d rather like to use a table component
Any help/hints appreciated