From a0b5c980f8f73a8b1093ccca8f842cc860f472b7 Mon Sep 17 00:00:00 2001 From: Mathias Polligkeit Date: Sun, 10 Dec 2023 14:11:10 +0900 Subject: [PATCH] handle radio options without label --- lib/doggo.ex | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/doggo.ex b/lib/doggo.ex index 1861f034..617c2532 100644 --- a/lib/doggo.ex +++ b/lib/doggo.ex @@ -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>