Skip to content

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

@Sgoettschkes

Description

@Sgoettschkes

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions