tfwright / live_admin

Low-config admin UI for Phoenix apps, built on LiveView
MIT License
251 stars 22 forks source link

Fix field_class form Ecto.UUID #43

Closed Rio517 closed 1 year ago

Rio517 commented 1 year ago

I saw you ran into a similar issue with https://github.com/tfwright/live_admin/commit/31f76dcec8d65a72ac6f97fb0bb4a40cb99836e9

The same issue occurs if a field is Ecto.UUID.

** (FunctionClauseError) no function clause matching in LiveAdmin.Components.Container.Form.field_class/1
    (live_admin 0.8.0) lib/live_admin/components/resource/form.ex:471: LiveAdmin.Components.Container.Form.field_class(Ecto.UUID)
    (live_admin 0.8.0) lib/live_admin/components/resource/form.ex:238: anonymous fn/2 in LiveAdmin.Components.Container.Form.field/1
    (live_admin 0.8.0) /home/mario/code/wunderwork/petal_ww/deps/live_admin/lib/live_admin/components/resource/form.ex:66: LiveAdmin.Components.Container.Form.render/1
    (elixir 1.14.4) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.14.4) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:486: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:538: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:384: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:538: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:384: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:538: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:384: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:711: Phoenix.LiveView.Diff.render_component/9
    (phoenix_live_view 0.19.3) lib/phoenix_live_view/diff.ex:657: anonymous fn/5 in Phoenix.LiveView.Diff.render_pending_components/6
    (elixir 1.14.4) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
tfwright commented 1 year ago

Resolve in https://github.com/tfwright/live_admin/commit/2fb36e99479a3f152810dcc4ee9be31f79bd2442

Ecto.UUID is not currently a supported field, so for now I just added a generic class to handle all of those cases. It might be desirable to generate classes even for unsupported fields but that will probably require a bit more thought and can be treated as a further enhancement.