aesmail / aesmail/kaffy

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

Aberta
#334 0 comentários 0 reações 1 responsável Reivindicada por @aesmail Ver no GitHub
bug
Linguagem predominante
Elixir
Estrelas
1.4k
Forks
171
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

**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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.