aesmail / aesmail/kaffy

[BUG] Create/Update not showing field for primary_key with autogenerate: false

Đang mở
#334 0 bình luận 0 reaction 1 người được giao Được @aesmail nhận Xem trên GitHub
bug
Ngôn ngữ chính
Elixir
Star
1.4k
Fork
171
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Versions Used**
Kaffy: 0.10.3
Phoenix: 1.7.10
Elixir:

Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.18.2 (compiled with Erlang/OTP 27)

**What's actually happening?**

As described in #333, we have a model which does not have a traditional primary_key. To work around the issue raised, I did define the primary_key on the `id` field but set it to `autogenerate: false`. This resolves the issue on the list page, but now the id field does not show up on the create or update page of the entity. The schema now looks as follows:

```
@primary_key {:id, :string, autogenerate: false}
schema "auth_identity_provider" do
field :name, :string

timestamps(type: :utc_datetime)
end
```

**What should happen instead?**

If the field is not auto generated, an input field should be automatically available on create. On update, I am not sure if the field should be readonly or not.

I understand this can be solved by manually adding the `id` field to the `form_fields/1`:

```
def form_fields(_) do
[
id: %{update: :readonly},
name: nil
]
end
```

Given that kaffy tries to create a valid create/update form for models out of the box and for the model above saving without providing a primary key fails, I think this should be considered a bug.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.