Hello, I am trying to get real time validation for a datepicker, but for some reason there is no error tag in the HTML Document.
<%= datetime_select @f, :ends_at, builder: &builder/1 %>
<%= error_tag_live(@f, :ends_at) |> IO.inspect() %>
def error_tag_live(form, field) do
Enum.map(Keyword.get_values(form.errors, field), fn error ->
content_tag(:span, translate_error(error),
class: "help-block",
data: [phx_error_for: input_id(form, field)]
)
end)
end
If there is an error message it print an error tag, as expected
[
safe: [
60,
"span",
[
[32, "class", 61, 34, "help-block", 34],
[32, "data-phx-error-for", 61, 34, "event_ends_at", 34]
],
62,
"The stream cannot end before it started",
60,
47,
"span",
62
]
]
The error-message however is nowhere to be seen in the HTML-document.
datetime_select
doesn’t return a tag with id “event_ends_at”, but multiple others like “event_ends_at_minute”.
Could it be that LiveView removes an error tag, if no corresponding id was found?
I have an error tag with the name :name
in the same file. which prints a similar tag in the console and renders perfectly fine.