View Source LiveAdmin.Resource (LiveAdmin v0.11.5)

API for managing Ecto schemas and their individual record instances used internally by LiveAdmin.

use LiveAdmin.Resource

This is required in any module that should act as a LiveAdmin Resource. If the module is not an Ecto schema, then the :schema option must be passed. Using this module will create a live_admin_config module variable and 2 functions to query it, live_admin_config/0 and live_admin_config/1. The former returns the entire config while the latter will return a key if it exists, otherwise it will fallback to either a global config for that key, or the key's default value.

To customize UI behavior, the following options may also be used:

  • title_with - a binary, or MFA that returns a binary, used to identify the resource
  • label_with - a binary, or MFA that returns a binary, used to identify records
  • list_with - an atom or MFA that identifies the function that implements listing the resource
  • create_with - an atom or MFA that identifies the function that implements creating the resource (set to false to disable create)
  • update_with - an atom or MFA that identifies the function that implements updating a record (set to false to disable update)
  • delete_with - an atom or MFA that identifies the function that implements deleting a record (set to false to disable delete)
  • validate_with - an atom or MFA that identifies the function that implements validating a changed record
  • render_with - an atom or MFA that identifies the function that implements table field rendering logic
  • hidden_fields - a list of fields that should not be displayed in the UI
  • immutable_fields - a list of fields that should not be editable in forms
  • actions - list of atoms or MFAs that identify a function that operates on a record
  • tasks - list atoms or MFAs that identify a function that operates on a resource
  • components - keyword list of component module overrides for specific views (:list, :new, :edit, :home, :nav, :session, :view)
  • ecto_repo - Ecto repo to use when building queries for this resource

Link to this section Summary

Link to this section Functions

Link to this function

all(ids, resource, prefix, repo)

View Source
Link to this function

change(resource, record \\ nil, params \\ %{})

View Source
Link to this function

create(resource, params, session, repo)

View Source
Link to this function

default_config_value(key)

View Source
Link to this function

delete(record, resource, session, repo)

View Source
Link to this function

find(id, resource, prefix, repo)

View Source
Link to this function

find!(id, resource, prefix, repo)

View Source
Link to this function

list(resource, opts, session, repo)

View Source
Link to this function

render(record, field, resource, assoc_resource, session)

View Source
Link to this function

update(record, resource, params, session)

View Source
Link to this function

validate(changeset, resource, session)

View Source