Shadix.Form (shadix v0.0.1)

Copy Markdown View Source

Form-integration helpers shared by Shadix form controls.

field_attrs/1 normalizes a Phoenix.HTML.FormField into plain attrs the controls render from. Isolating normalization here keeps the controls simple and makes a future low-level (name/value) escape hatch a one-place, additive change.

Summary

Functions

Normalizes a Phoenix.HTML.FormField into %{id, name, value, errors} (errors translated to strings).

Translates a changeset error {msg, opts} into a string, interpolating %{key} placeholders. Non-gettext fallback (a component library cannot assume the host's gettext backend).

Functions

field_attrs(field)

Normalizes a Phoenix.HTML.FormField into %{id, name, value, errors} (errors translated to strings).

translate_error(arg)

Translates a changeset error {msg, opts} into a string, interpolating %{key} placeholders. Non-gettext fallback (a component library cannot assume the host's gettext backend).