aesmail / aesmail/kaffy

[BUG] expected a map, got: nil when using custom form_field

Aberta
#256 6 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.9.4
Phoenix: 1.6.9
Elixir: 1.14.2

**What's actually happening?**
If I configure `resources` manually, I get error on **edit**, **create**, or **update**.
> expected a map, got: nil when using custom form_field

Here's the configuration I am using:
```
config :kaffy,
admin_title: "MyApp Admin",
otp_app: :my_app,
ecto_repo: MyApp.Repo,
router: MyAppWeb.Router,
resources: &MyApp.Kaffy.Config.create_resources/1
```
If I don't use `resources` in config, then everything works. However, I need to have custom form fields for some resources.

This is one of my configurations:

```
defmodule MyApp.Kaffy.BenchmarkAdmin do
@doc """

"""
def form_fields(_) do
[
friendly_name: nil,
stages: nil,
organization_id: nil
]
end
end

```

Here's the `Config.create_resources`

```
defmodule MyApp.Kaffy.Config do
def create_resources(_conn) do
[
...
benchmarks: [
name: "Benchmarks",
resources: [
benchmarks: [schema: MyApp.Benchmarks.Benchmark, admin: MyApp.Kaffy.BenchmarkAdmin],
#even if I don't pass `:admin`, the views don't work for creating/ updating resources.
benchmark_stages: [schema: MyApp.Benchmarks.BenchmarkStage],
]
]
]
end
end
```

**What should happen instead?**
The resource should be created with the given parameters (NOTE: the changeset only requires `friendly_name` but apparently even that is nil.)

**Screenshots**
If applicable, add screenshots to help explain your problem.
![Screen Shot 2023-01-02 at 15 37 28](https://user-images.githubusercontent.com/15087925/210245729-2dfd8e6e-556c-468b-b61a-f4f8adf3aefc.png)

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.