I have a function that generates a date_picker
, after upgrading to live_view
0.18.3, I am getting warnings, about assigning variable b
outside of my ~H
sigil.
This is the function, can anyone tell me how best to rewrite it?
def date_picker(form, field, opts \\ []) do
{myself, opts} = Keyword.pop(opts, :myself)
assigns = %{myself: myself}
builder = fn b ->
~H"""
<div class="flex">
<%= b.(:year,
options: 2008..2099,
class:
"mt-1 mr-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md",
phx_keydown: "stop_edit",
phx_key: "escape",
phx_hook: "AutoFocus",
phx_target: @myself
) %>
<%= b.(:month,
class:
"mt-1 mr-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md",
phx_keydown: "stop_edit",
phx_key: "escape",
phx_target: @myself
) %>
<%= b.(:day,
class:
"mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md",
phx_keydown: "stop_edit",
phx_key: "escape",
phx_target: @myself
) %>
</div>
"""
end
date_select(form, field, [builder: builder] ++ opts)
end