@@ -124,13 +124,13 @@ defmodule Kaffy.ResourceForm do
124124 :id ->
125125 case field in Kaffy.ResourceSchema . primary_keys ( schema ) do
126126 true -> text_input ( form , field , opts )
127- false -> text_or_assoc ( conn , schema , form , field , opts )
127+ false -> text_or_assoc ( conn , schema , form , field , type , opts )
128128 end
129129
130130 t when t in [ :binary_id , Ecto.ULID ] ->
131131 case field in Kaffy.ResourceSchema . primary_keys ( schema ) do
132132 true -> text_input ( form , field , opts )
133- false -> text_or_assoc ( conn , schema , form , field , opts )
133+ false -> text_or_assoc ( conn , schema , form , field , type , opts )
134134 end
135135
136136 :string ->
@@ -351,7 +351,7 @@ defmodule Kaffy.ResourceForm do
351351 end
352352 end
353353
354- defp text_or_assoc ( conn , schema , form , field , opts ) do
354+ defp text_or_assoc ( conn , schema , form , field , type , opts ) do
355355 actual_assoc =
356356 Enum . filter ( Kaffy.ResourceSchema . associations ( schema ) , fn a ->
357357 Kaffy.ResourceSchema . association ( schema , a ) . owner_key == field
@@ -376,12 +376,22 @@ defmodule Kaffy.ResourceForm do
376376
377377 content_tag :div , class: "input-group" do
378378 [
379- number_input ( form , field ,
380- class: "form-control" ,
381- id: field ,
382- disabled: opts [ :readonly ] ,
383- aria_describedby: field
384- ) ,
379+ case type do
380+ :id ->
381+ number_input ( form , field ,
382+ class: "form-control" ,
383+ id: field ,
384+ disabled: opts [ :readonly ] ,
385+ aria_describedby: field
386+ )
387+ _ ->
388+ text_input ( form , field ,
389+ class: "form-control" ,
390+ id: field ,
391+ disabled: opts [ :readonly ] ,
392+ aria_describedby: field
393+ )
394+ end ,
385395 if opts [ :readonly ] do
386396 ""
387397 else
@@ -443,7 +453,12 @@ defmodule Kaffy.ResourceForm do
443453 end
444454
445455 false ->
446- number_input ( form , field , opts )
456+ case type do
457+ :id ->
458+ number_input ( form , field , opts )
459+ _ ->
460+ text_input ( form , field , opts )
461+ end
447462 end
448463 end
449464
0 commit comments