SelectoComponents.ActionFormHost (selecto_components v0.4.8)

Host-side helpers for wiring SelectoComponents.Modal.ActionFormModal.

The modal owns form rendering and request construction. The host still owns preview/apply execution, but can delegate the common LiveView state updates to this module.

Link to this section Summary

Link to this section Functions

Link to this function

assign_error(socket, message, reason \\ nil)

Link to this function

assign_result(socket, intent, result, metadata \\ %{})

Link to this function

handle_submit(socket, payload, opts)

Handles a {:selecto_action_form_submit, payload} message.

Required options:

  • :preview - callback invoked as (action_id, request, socket)
  • :apply - callback invoked as (action_id, request, socket)

Optional options:

  • :after_apply - callback invoked as (socket, result) before modal result assignment. It may return the updated socket or {socket, reload_metadata} when the host refreshed data after the write.
  • :authorize - callback invoked before preview/apply execution. It may be arity 4 (action_id, request, socket, intent) or arity 3 (action_id, request, socket). Return :ok, {:ok, metadata}, or {:error, reason}.
  • :format_error - callback invoked as (reason) for host-specific error messages
Link to this function

update_component_assigns(socket, updates)