Normalizes Phoenix.HTML.Form values for React clients.
Form metadata is deliberately limited to a monotonic client revision. Submit results use a dedicated LiveView push event because React may coalesce consecutive prop snapshots before committing either one.
Ecto relations present in a changeset are normalized recursively. Unchanged
embeds with an explicit cast callback are also normalized so their required
tree remains available. Unchanged associations stay as leaf values and are
left to LiveViewReact.Encoder; this prevents implicit traversal of loaded,
bidirectional association graphs.
Summary
Types
A JavaScript-safe, non-negative form revision.
Functions
Pushes the reply for a native LiveView form submission.
Returns a new form with validated LiveViewReact metadata.
Copies the exact LiveViewReact revision field from event params onto a form.
Types
Functions
@spec reply(Phoenix.LiveView.Socket.t(), Phoenix.HTML.Form.t(), term()) :: Phoenix.LiveView.Socket.t()
Pushes the reply for a native LiveView form submission.
The event is dispatched before the accompanying DOM patch so a subsequent validation render cannot erase a one-shot result. React clients correlate the event by form ID, form name, and revision. The updated socket is returned and the input form remains unchanged.
@spec with_metadata(Phoenix.HTML.Form.t(), Keyword.t()) :: Phoenix.HTML.Form.t()
Returns a new form with validated LiveViewReact metadata.
Only :revision is accepted. The original form and its source are never
mutated. Omitting it preserves the current revision, or uses zero when the
form has none.
@spec with_revision_from_params(Phoenix.HTML.Form.t(), map()) :: Phoenix.HTML.Form.t()
Copies the exact LiveViewReact revision field from event params onto a form.
The params map may contain ordinary application fields, but only
"_liveview_react_revision" is read. A missing field raises instead of silently
accepting an uncorrelated server response.