You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/lib/plausible_web/views/error_helpers.ex

18 lines
456 B
Elixir

7 years ago
defmodule PlausibleWeb.ErrorHelpers do
use Phoenix.HTML
def error_tag(%Phoenix.HTML.Form{} = form, field) do
7 years ago
Enum.map(Keyword.get_values(form.errors, field), fn error ->
content_tag(:div, elem(error, 0), class: "mt-2 text-sm text-red-600")
7 years ago
end)
end
def error_tag(assigns, field) when is_map(assigns) do
error = assigns[field]
if error do
content_tag(:div, error, class: "mt-2 text-sm text-red-600")
end
end
7 years ago
end