Skip to content

Commit

Permalink
Merge pull request #40 from naymspace/feature/value-for-select
Browse files Browse the repository at this point in the history
Use value in select field input
  • Loading branch information
Flo0807 authored Jan 3, 2024
2 parents 9882c2a + 7d50d9a commit 9463b4c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 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 Down

0 comments on commit 9463b4c

Please sign in to comment.