Skip to content

Commit

Permalink
handle radio options without label
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Dec 10, 2023
1 parent 9baf900 commit a0b5c98
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/doggo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,22 @@ defmodule Doggo do
defp field_error_class(_), do: "has-errors"

defp radio(%{option: {option_label, option_value}} = assigns) do
assigns = assign(assigns, label: option_label, option_value: option_value)
assigns
|> assign(label: option_label, option_value: option_value, option: nil)
|> radio()
end

defp radio(%{option: option_value} = assigns) do
assigns
|> assign(
label: Form.humanize(option_value),
option_value: option_value,
option: nil
)
|> radio()
end

defp radio(%{option_value: _} = assigns) do
~H"""
<.label>
<input
Expand Down

0 comments on commit a0b5c98

Please sign in to comment.