Skip to content

Commit

Permalink
Use value in select field input
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo0807 committed Jan 3, 2024
1 parent d50437d commit 60f1a61
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/backpex/html/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ defmodule Backpex.HTML.Form do
end

def field_input(%{type: "select"} = assigns) do
rest = if Map.get(assigns, :value), do: Map.put(assigns.rest, :value, assigns.value), else: assigns.rest

assigns =
assigns
|> assign(:rest, rest)
|> assign_new(:errors, fn -> Keyword.get_values(assigns.form.errors || [], assigns.field_name) end)

~H"""
Expand All @@ -107,7 +110,7 @@ defmodule Backpex.HTML.Form do
@form,
@field_name,
@options,
Map.to_list(@rest)
Map.to_list(@rest) |> IO.inspect()
) %>
</div>
<.error_tag form={@form} name={@field_name} field_options={@field_options} />
Expand Down

0 comments on commit 60f1a61

Please sign in to comment.