PhoenixFilament.Resource behaviour (PhoenixFilament v0.1.0)

Copy Markdown View Source

Declares an admin resource backed by an Ecto schema.

Usage

defmodule MyApp.Admin.PostResource do
  use PhoenixFilament.Resource,
    schema: MyApp.Blog.Post,
    repo: MyApp.Repo
end

Options

  • :schema (atom/0) - Required. The Ecto schema module

  • :repo (atom/0) - Required. The Ecto repo module

  • :label (String.t/0) - Human-readable resource name (auto-derived from schema if omitted)

  • :plural_label (String.t/0) - Plural form of label

  • :icon (String.t/0) - Icon name for panel navigation

  • :create_changeset - Changeset function as {Module, :function_name} tuple for create. Called as Module.function_name(struct, params). Default: {schema, :changeset} The default value is nil.

  • :update_changeset - Changeset function as {Module, :function_name} tuple for update. Called as Module.function_name(record, params). Default: {schema, :changeset} The default value is nil.

Summary

Callbacks

Callback to retrieve resource metadata.

Callbacks

__resource__(atom)

@callback __resource__(:schema) :: module()
@callback __resource__(:repo) :: module()
@callback __resource__(:opts) :: keyword()
@callback __resource__(:form_fields) :: [PhoenixFilament.Field.t()]
@callback __resource__(:form_schema) :: [
  PhoenixFilament.Field.t()
  | PhoenixFilament.Form.Section.t()
  | PhoenixFilament.Form.Columns.t()
]
@callback __resource__(:table_columns) :: [PhoenixFilament.Column.t()]
@callback __resource__(:table_actions) :: [PhoenixFilament.Table.Action.t()]
@callback __resource__(:table_filters) :: [PhoenixFilament.Table.Filter.t()]

Callback to retrieve resource metadata.

Valid keys: [:schema, :repo, :opts, :form_fields, :form_schema, :table_columns, :table_actions, :table_filters]