ErrorTag
A component inspired by error_tag/3
that ships with mix phx.new
in
MyAppWeb.ErrorHelpers
Renders error messages if any exist regarding the given field.
Error Translation
Changeset errors are translated using the default error translator
that ships with phoenix when generated with mix phx.new --no-gettext
.
When using Gettext, you can use configuration to route all errors through
the MyAppWeb.ErrorHelpers.translate_error/1
function generated by Phoenix,
which utilizes Gettext
. You need to provide a tuple with the module and
the name of the function (as an atom) as follows:
config :surface, :components, [
{Surface.Components.Form.ErrorTag, translator: {MyAppWeb.ErrorHelpers, :translate_error}}
]
There is also a translator
prop which can be used on a case-by-case basis.
It overrides the configuration.