diff --git a/lib/petal_components/field.ex b/lib/petal_components/field.ex index 1305959..24ecf11 100644 --- a/lib/petal_components/field.ex +++ b/lib/petal_components/field.ex @@ -39,7 +39,7 @@ defmodule PetalComponents.Field do attr :size, :string, default: "md", values: ~w(xs sm md lg xl), - doc: "the size of the switch or radio card" + doc: "the size of the switch (xs, sm, md, lg or xl) or radio card (sm, md or lg)" attr :variant, :any, default: "outline", doc: "outline, classic - used by radio-card" @@ -321,7 +321,6 @@ defmodule PetalComponents.Field do assigns = assigns |> assign_new(:checked, fn -> nil end) - |> assign_new(:class, fn -> "" end) |> assign_new(:options, fn -> [] end) |> assign_new(:group_layout, fn -> "row" end) |> assign_new(:id_prefix, fn -> assigns.id || assigns.name || "radio_card" end) diff --git a/test/petal/field_test.exs b/test/petal/field_test.exs index fba74f4..68bdf27 100644 --- a/test/petal/field_test.exs +++ b/test/petal/field_test.exs @@ -531,6 +531,19 @@ defmodule PetalComponents.FieldTest do assert html =~ "custom-class" end + test "field radio-card group_layout attr" do + assigns = %{form: to_form(%{}, as: :user)} + + html = + rendered_to_string(~H""" + <.form for={@form}> + <.field type="radio-card" field={@form[:plans]} /> + + """) + + assert html =~ "pc-radio-card-group--row" + end + test "field radio-card checked on form field" do assigns = %{form: to_form(%{"plans" => "pro"}, as: :user)}