BitstylesPhoenix.Component.Error.ui_errors

You're seeing just the function ui_errors, go back to BitstylesPhoenix.Component.Error module for more information.

Render errors from a Phoenix.HTML.Form.

Attributes

  • form (required) - The form to render the input form.
  • field (required) - The name of the field for the input.
  • class - Extra classes to pass to the wrapping ul if there are mutliple errors. See BitstylesPhoenix.Helper.classnames/1 for usage.
  • error_class - Extra classes to pass to the error component. See BitstylesPhoenix.Helper.classnames/1 for usage.

See also BitstylesPhoenix.Component.Form.

Uses the translate_errors MFA from the config to translate field errors (e.g. with gettext).

A single error

iex> assigns = %{form: @form_with_errors}
...> render ~H"""
...> <.ui_errors form={@form} field={:single} />
...> """
"""
<span class="u-fg-warning" phx-feedback-for="user[single]">
  is too short
</span>
"""

Multiple errors

iex> assigns = %{form: @form_with_errors}
...> render ~H"""
...> <.ui_errors form={@form} field={:multiple} />
...> """
"""
<ul class="u-padding-xl-left">
  <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>
"""