Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document default_actions #289

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,16 @@ defmodule MyApp.Blog.PostAdmin do
end
```

If you need to hide the "New <Schema>" button, you can define the `default_actions/1` function in your admin module:

```elixir
defmodule MyApp.Blog.PostAdmin do
def default_actions(_schema) do
# default actions are [:new, :edit, :delete] by default.
[:delete] # cannot create or edit posts, can only delete.
end
end
```

### Form Pages

Expand Down Expand Up @@ -519,6 +529,17 @@ def form_fields(_schema) do
]
```

If you don't want users to be able to edit or delete records, you can define the `default_actions/1` function in your admin module:

```elixir
defmodule MyApp.Blog.PostAdmin do
def default_actions(_schema) do
# default actions are [:new, :edit, :delete] by default.
[:new] # only create records, cannot edit or delete.
end
end
```

#### Association Forms

A `belongs_to` association should be referenced by the field name, *not* the association name. For example, a schema with the following association:
Expand Down
Loading