ExTeal.Field behaviour (ExTeal v0.21.0) View Source

The core struct that represents a field on a resource served by ExTeal.

Link to this section Summary

Functions

Override the default filter for the field.

Use a getter function to display a computed field on the resource.

Define the options for the select field. The function accepts a list of options that are either strings or maps with of value and label keys. If the list members are strings, the value will be used for both the value and label of the <option> element it represents.

Link to this section Types

Specs

t() :: %ExTeal.Field{
  as_html: term(),
  attribute: term(),
  can_see: term(),
  component: term(),
  embed_field: term(),
  field: term(),
  filterable: term(),
  getter: term(),
  name: term(),
  options: term(),
  panel: term(),
  pivot_field: term(),
  prefix_component: term(),
  private_options: term(),
  relationship: term(),
  sanitize: term(),
  show_on_detail: term(),
  show_on_edit: term(),
  show_on_index: term(),
  show_on_new: term(),
  sortable: term(),
  text_align: term(),
  type: term(),
  value: term()
}

Link to this section Callbacks

Link to this callback

apply_options_for(t, struct, struct, atom)

View Source

Specs

apply_options_for(t(), struct(), struct(), atom()) :: t()

Specs

default_sortable() :: boolean()

Specs

filterable_as() :: ExTeal.FieldFilter.valid_type()

Specs

make(atom(), String.t() | nil) :: t()

Specs

sanitize_as() :: atom() | false
Link to this callback

value_for(t, struct, atom)

View Source

Specs

value_for(t(), struct(), atom()) :: any()

Link to this section Functions

Link to this function

filter_as(field, filter_module)

View Source

Specs

filter_as(t(), module()) :: t()

Override the default filter for the field.

Use a getter function to display a computed field on the resource.

The getter function is given a schema and expects a string result

Link to this function

nested_value_for(field, model)

View Source
Link to this function

struct_from_field(implementation, name, label)

View Source
Link to this function

transform_options(options)

View Source

Define the options for the select field. The function accepts a list of options that are either strings or maps with of value and label keys. If the list members are strings, the value will be used for both the value and label of the <option> element it represents.

options are expected to be an enumerable which will be used to generate each respective option. The enumerable may have:

  • keyword lists - each keyword list is expected to have the keys :key and :value. Additional keys such as :disabled may be given to customize the option

  • two-item tuples - where the first element is an atom, string or integer to be used as the option label and the second element is an atom, string or integer to be used as the option value

  • atom, string or integer - which will be used as both label and value for the generated select

Optgroups

If options is a map or keyword list where the firs element is a string, atom, or integer and the second element is a list or a map, it is assumed the key will be wrapped in an <optgroup> and teh value will be used to generate <options> nested under the group. This functionality is only handled in the UI for select fields, boolean groups will not respond.

This functionality is equivalent to Phoenix.HTML.Form.select/3

Link to this function

value_for(field, model, type)

View Source