From 4f52323a2e98986e4e47d18264dff98740d4b15d Mon Sep 17 00:00:00 2001 From: Abdullah Esmail Date: Sun, 10 Sep 2023 00:38:03 +0300 Subject: [PATCH] document default_actions --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index dbf36168..89acb9e9 100644 --- a/README.md +++ b/README.md @@ -454,6 +454,16 @@ defmodule MyApp.Blog.PostAdmin do end ``` +If you need to hide the "New " 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 @@ -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: