<form
id="select-outcome"
phx-change="update-outcome"
phx-value-entry_id={entry.id}
class="flex justify-between items-center pl-6"
>
<.input
type="select"
name="outcome_selector"
value={nil}
disabled={assigns.read_only}
options={@treatment_options}
/>
</form>
def handle_event(
"update-outcome",
%{"entry_id" => entry_id, "outcome_selector" => treatment_id},
socket
) do
treatment = Cvs.Event.Treatment.get_by_id!(treatment_id, actor: socket.assigns.current_user)
entry = Cvs.MatchingTable.Entry.get_by_id!(entry_id, actor: socket.assigns.current_user)
Cvs.MatchingTable.Entry.assign_to_matching_table!(
entry,
%{
treatment_id: treatment.id
},
actor: socket.assigns.current_user
)
{:noreply, socket}
end
I get this form and handle_event which work fine but I just cant get my test to work and I dont understand what Im doing wrong.
html =
edit_live
|> form("#select-outcome", %{outcome_selector: t1.id})
|> render_change()
Gives me that it expects def handle_event("update-outcome", %{"entry_id" => entry_id, "outcome_selector" => treatment_id}, socket)
and cant match it which makes sense.
But with
html =
edit_live
|> form("#select-outcome", %{entry_id: first_entry.id, outcome_selector: t1.id})
|> render_change()
It gives ** (ArgumentError) could not find non-disabled input, select or textarea with name "entry_id" within
which also makes sense but now I dont know how to actually get it working?