BitstylesPhoenix.Error (bitstyles_phoenix v0.6.0) View Source
Component for showing UI errors.
Link to this section Summary
Link to this section Functions
Generates tag for custom errors.
When errors are given in tuples {error, error_opts} they are given to the translate_errors
callback.
The error will be rendered with the warning color, as specified in bitstyles colors.
An error tag
iex> safe_to_string ui_error_tag("Foo error")
~s(<span class="u-fg--warning">Foo error</span>)
An error tag with a gettext tuple (processed by the default callback)
iex> safe_to_string ui_error_tag({"Foo error", count: 1})
~s(<span class="u-fg--warning">Foo error</span>)
An error tag with options
iex> safe_to_string ui_error_tag("Foo error", phx_feedback_for: "foo")
~s(<span class="u-fg--warning" phx-feedback-for="foo">Foo error</span>)
Generates tag for inlined form input errors.
Uses the translate_errors
callback to translate field errors.
A single error
iex> safe_to_string ui_errors(@error_form, :single)
~s(<span class="u-fg--warning" phx-feedback-for="user_single">is too short</span>)
Multiple errors
iex> safe_to_string ui_errors(@error_form, :multiple)
~s(<ul class="u-padding-l-left u-fg--warning">
<li><span class="u-fg--warning" phx-feedback-for="user_multiple">is simply bad</span></li>
<li><span class="u-fg--warning" phx-feedback-for="user_multiple">not fun</span></li>
</ul>
)