Shared form handling runtime for both LiveView and Component.
This module contains the common logic for form operations:
extract_resource/1- Extract Ash resource from various form typesextract_changeset/1- Extract Ash changeset from various form typesextract_submit_errors/1- Turn an Ash submit failure into a per-field error mapbroadcast_mutation/1- Broadcast mutation events for PubSub invalidationresolve_actor/1- Look up the Ash actor for asubmitop
Summary
Functions
Broadcast mutation to all relevant PubSub topics.
Extract the Ash changeset from various form types.
Extract the Ash resource module from various form types.
Extract per-field errors from an Ash submit failure for storage in _server_errors state.
Resolve the Ash actor to pass to Lavash.Form.submit/2 for a
submit :field action op.
Functions
Broadcast mutation to all relevant PubSub topics.
Uses the resource's notify_on configuration from Lavash.Resource extension to enable fine-grained invalidation based on filter combinations.
Extract the Ash changeset from various form types.
Supports:
Lavash.Formwith embedded changesetPhoenix.HTML.Form(recurses into source)AshPhoenix.Formwith Ash.Changeset sourceAsh.Changesetdirectly
Extract the Ash resource module from various form types.
Supports:
Lavash.Formwith embedded changesetAsh.ChangesetAshPhoenix.FormPhoenix.HTML.Form(recurses into source)
Extract per-field errors from an Ash submit failure for storage in _server_errors state.
Returns a map of %{"field_name" => ["error message", ...]}.
@spec resolve_actor(map() | Phoenix.LiveView.Socket.t()) :: any()
Resolve the Ash actor to pass to Lavash.Form.submit/2 for a
submit :field action op.
Lookup order:
socket.assigns[:actor]— the explicit, transport-agnostic prop. Components should accept this when they need to act on behalf of someone (they don't auto-receive:current_userbecause that's anon_mountinjection, which only runs on LiveViews).socket.assigns[:current_user]— the conventional AshAuthentication assign. LiveViews underlive_session ..., on_mount: AshAuthentication.LiveSessionget this for free; for themsubmitJust Works without any host-side wiring.nil— no actor available. Submits that depend on an actor (relate_actor/1, policy checks, etc.) will fail with an Ash changeset error.