I’m trying to pass along some extra data when a select input is changed. So here is my form
<.form for={ChangeItemDC} phx-change="change_item_dc" phx-value-scrubitem={scrub_item.id}>
<select name="dc_id" phx-value-test={scrub_item.id}>
<.dc_options selected_dc={@selected_dc} dcs={@dcs} />
</select>
</.form>
In the code above I’ve added the phx-value-*
to both the form and the select statement, I only need 1 of them to work but I was testing around different elements to see if the param would get passed in
Here is the event handler
def handle_event("change_item_dc", params, socket) do
IO.inspect(params)
{:noreply, socket}
end
Which ends up outputting
%{"_target" => ["dc_id"], "dc_id" => "61"}
As you can see both phx-value-*
values aren’t being passed in. I’ve tried adding it to the <option>
element as well but still nothing changed. How could I get this meta data for an onchange event for a select element? Essentially I would like the params to be
%{"_target" => ["dc_id"], "dc_id" => "61", "scrubitem" => "10"}