Skip to content

Commit 9db874a

Browse files
committed
handle binary_ids and models without strings.
1 parent af20b30 commit 9db874a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/kaffy/resource_form.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ defmodule Kaffy.ResourceForm do
107107
false -> text_or_assoc(conn, schema, form, field, opts)
108108
end
109109

110+
:binary_id ->
111+
case Kaffy.ResourceSchema.primary_key(schema) == [field] do
112+
true -> text_input(form, field, opts)
113+
false -> text_or_assoc(conn, schema, form, field, opts)
114+
end
115+
110116
:string ->
111117
text_input(form, field, opts)
112118

@@ -304,7 +310,7 @@ defmodule Kaffy.ResourceForm do
304310

305311
string_field =
306312
case is_nil(popular_strings) do
307-
true -> Enum.at(string_fields, 0) |> elem(0)
313+
true -> (Enum.at(string_fields, 0) || {:id}) |> elem(0)
308314
false -> elem(popular_strings, 0)
309315
end
310316

0 commit comments

Comments
 (0)