@@ -124,13 +124,13 @@ defmodule Kaffy.ResourceForm do
124
124
:id ->
125
125
case field in Kaffy.ResourceSchema . primary_keys ( schema ) do
126
126
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 )
128
128
end
129
129
130
130
t when t in [ :binary_id , Ecto.ULID ] ->
131
131
case field in Kaffy.ResourceSchema . primary_keys ( schema ) do
132
132
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 )
134
134
end
135
135
136
136
:string ->
@@ -351,7 +351,7 @@ defmodule Kaffy.ResourceForm do
351
351
end
352
352
end
353
353
354
- defp text_or_assoc ( conn , schema , form , field , opts ) do
354
+ defp text_or_assoc ( conn , schema , form , field , type , opts ) do
355
355
actual_assoc =
356
356
Enum . filter ( Kaffy.ResourceSchema . associations ( schema ) , fn a ->
357
357
Kaffy.ResourceSchema . association ( schema , a ) . owner_key == field
@@ -376,12 +376,22 @@ defmodule Kaffy.ResourceForm do
376
376
377
377
content_tag :div , class: "input-group" do
378
378
[
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 ,
385
395
if opts [ :readonly ] do
386
396
""
387
397
else
@@ -443,7 +453,12 @@ defmodule Kaffy.ResourceForm do
443
453
end
444
454
445
455
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
447
462
end
448
463
end
449
464
0 commit comments