MishkaGervaz.Form.Web.Events.RelationHandler behaviour
(MishkaGervaz v0.0.1-alpha.3)
Copy Markdown
View Source
Handles relation field events for search, multi-select, and dropdown state.
Follows the same pattern as MishkaGervaz.Table.Web.Events.RelationFilterHandler.
Events Handled
search- Search options by term (debounced)focus- Open dropdown and load initial optionsclose_dropdown- Close dropdown on click-awayselect- Single select (for :search mode)toggle- Toggle selection (for :search_multi mode)clear- Clear all selectionsload_more- Load next page of options
Customization
defmodule MyApp.Form.RelationHandler do
use MishkaGervaz.Form.Web.Events.RelationHandler
def handle("toggle", params, state, socket) do
super("toggle", params, state, socket)
end
endTop-level helpers (get_field/2, get_search_term/2,
validate_min_chars/2, resolve_selected_options/3, revalidate_form/3,
update_relation_state/5, reload_dependent_fields/3, etc.) are public
so user overrides can reuse them — they live outside the __using__
macro to avoid per-consumer compile cost.
See MishkaGervaz.Form.Web.Events,
MishkaGervaz.Form.Web.DataLoader.RelationLoader, and the sibling
sub-handlers.
Summary
Types
@type params() :: map()
@type socket() :: Phoenix.LiveView.Socket.t()
@type state() :: MishkaGervaz.Form.Web.State.t()