MishkaGervaz.Form.Types.Field.Relation (MishkaGervaz v0.0.1-alpha.3)

Copy Markdown View Source

Relation field type for selecting related records in forms.

Follows the same pattern as MishkaGervaz.Table.Types.Filter.Relation.

Modes

  • :static - Load all options at once (default, for small datasets)
  • :load_more - Paginated with "Load more" button
  • :search - Searchable single select
  • :search_multi - Searchable multi select

Examples

field :site_id, :relation do
  mode :static
  display_field :name
end

field :category_id, :relation do
  mode :search_multi
  search_field :name
  min_chars 1
end

See MishkaGervaz.Form.Behaviours.FieldType, MishkaGervaz.Form.Types.Field, and the table-side counterpart MishkaGervaz.Table.Types.Filter.Relation.

Summary

Functions

Renders the relation field input by building assigns and calling the UI adapter.

Functions

render_input(field, rel_data, state_assigns, ui)

@spec render_input(map(), map(), map(), module()) :: Phoenix.LiveView.Rendered.t()

Renders the relation field input by building assigns and calling the UI adapter.

Delegates to the appropriate UI adapter function based on mode:

  • :staticui.select/1
  • :searchui.search_select/1
  • :load_moreui.load_more_select/1
  • :search_multiui.multi_select/1