Skip to content

Commit

Permalink
take the name from the radio input
Browse files Browse the repository at this point in the history
  • Loading branch information
fatboypunk committed Oct 21, 2021
1 parent a2c1652 commit 89cee46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/test_dispatch/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule TestDispatch.Form do
other_radios =
radios
|> Enum.uniq_by(fn {_, list, _} ->
list |> Enum.find(fn {key, _} -> "name" == key end) |> elem(1)
Enum.find(list, fn {key, _} -> "name" == key end) |> elem(1)
end)
|> Enum.reject(fn radio -> floki_attribute(radio, "name") in checked_names end)

Expand Down Expand Up @@ -138,10 +138,11 @@ defmodule TestDispatch.Form do
defp key_for_input({"button", _, _} = input, _), do: floki_attribute(input, "name")

defp key_for_input(input, _) do
name = floki_attribute(input, "name")
id = floki_attribute(input, "id")

if floki_attribute(input, "type") == "radio",
do: String.replace_suffix(id, "_#{floki_attribute(input, "value")}", ""),
do: name,
else: id
end

Expand Down

0 comments on commit 89cee46

Please sign in to comment.