Form.datetime_select/3 builder example uses deprecated `~e` sigil
michallepicki opened this issue · comments
https://hexdocs.pm/phoenix_html/3.1.0/Phoenix.HTML.Form.html#datetime_select/3-builder
The def my_datetime_select
example should probably use a ~H
sigil?
@michallepicki can you please check if it works with ~H, and if it does, send a PR? Thank you.
@michallepicki sorry, I couldn't figure it out, I settled on html_escape
for my use case for now (I'm using it in a regular dead view)
Did you get an error or something?
def my_datetime_select(form, field, opts \\ []) do
builder = fn b ->
~H"""
Date: <%= b.(:day, []) %> / <%= b.(:month, []) %> / <%= b.(:year, []) %>
Time: <%= b.(:hour, []) %> : <%= b.(:minute, []) %>
"""
end
datetime_select(form, field, [builder: builder] ++ opts)
end
Error:
warning: variable "assigns" does not exist and is being expanded to "assigns()", please use parentheses to remove the ambiguity or change the variable name
lib/ui/views/users_view.ex:81: UI.UsersView.my_datetime_select/3
== Compilation error in file lib/ui/views/users_view.ex ==
** (CompileError) lib/ui/views/users_view.ex:81: undefined function assigns/0
(elixir 1.12.2) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
(stdlib 3.15.2) erl_eval.erl:685: :erl_eval.do_apply/6
Maybe this needs to be a functional Phoenix.Component
? Not sure how/if that would work, I don't have experience with them yet
you always need an assigns attribute before, something like this would work:
assigns = %{b: b}
~H"""
"""
and then you use @b
inside.