Fix bug with date/datetime inputs

This commit is contained in:
Thelonius Kort
2023-01-01 00:22:40 +01:00
parent 40b1bedbe2
commit 07413802d9

View File

@ -337,6 +337,16 @@ defmodule OutlookWeb.CoreComponents do
""" """
end end
def input(assigns) when assigns.type in ~w(date datetime-local) and is_struct(assigns.value) do
format = case assigns.type do
"date" -> "%Y-%m-%d"
"datetime-local" -> "%Y-%m-%dT%H:%M"
end
assigns
|> assign(:value, Calendar.strftime(assigns.value, format))
|> input()
end
def input(assigns) do def input(assigns) do
~H""" ~H"""
<div phx-feedback-for={@name}> <div phx-feedback-for={@name}>