aesmail / aesmail/kaffy

[FEATURE-REQUEST] Allow custom fields on the view/edit page

Open
#332 0 comments 0 reactions 1 assignee Claimed by @aesmail View on GitHub
enhancement
Dominant language
Elixir
Stars
1.4k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you're proposing to solve**

When looking at the view/edit page for a model, in addition to the fields directly related to the model, I'd like to display values from related entities and/or composed values. For example, let's say our model is a user, and there is a 1:n relationship with a company. I don't want to display the company on the list page, because the table is already very large and it's not often that we need that information. To make it possible to look up which company a user belongs to, showing it in a readonly field on the view/edit page would be preferred.

A second use case is that, if a company has SSO enabled, there exists a link to the SSO metadata for this company. We do not need this link often, so it's not valuable to add it to the list of companies, but it would be great to show this link on the view/edit page for the company. This link can be build up by looking at a related entity in the database.

**Describe the solution you'd like**

Much like the `value` option on the list page, the `form_fields` could allow for fields to provide a function and display the return of that function in a read-only field.

Example:

```
def form_fields(_) do
[
email: nil,
username: nil,
first_name: nil,
last_name: nil,
company: %{label: "Company", value: fn (user) -> user.company.name end}
]
end
```

**Describe alternatives you've considered**

Another possibility would be to add a section below the form on the view/edit page and a function which can be defined in the Admin module. Whatever this function returns is what is displayed in that section. This would give even more flexibility but would also mean more/duplicate work styling this section.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.