Skip to content

Commit 06f8dcb

Browse files
committed
Switch to phoenix_html
1 parent 5ce67bf commit 06f8dcb

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lib/phoenix_html/form.ex

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,25 @@ defmodule Phoenix.HTML.Form do
334334
[acc | option(option_key, option_value, [], selected_values)]
335335

336336
options, acc when is_list(options) ->
337-
if not Keyword.has_key?(options, :key) do
338-
raise ArgumentError,
339-
"expected :key key when building <option> from keyword list: #{inspect(options)}"
340-
end
341-
342-
if not Keyword.has_key?(options, :value) do
343-
raise ArgumentError,
344-
"expected :value key when building <option> from keyword list: #{inspect(options)}"
345-
end
346-
347-
{option_key, options} = Keyword.pop(options, :key)
348-
{option_value, options} = Keyword.pop(options, :value)
337+
{option_key, options} =
338+
case List.keytake(options, :key, 0) do
339+
nil ->
340+
raise ArgumentError,
341+
"expected :key key when building <option> from keyword list: #{inspect(options)}"
342+
343+
{{:key, key}, options} ->
344+
{key, options}
345+
end
346+
347+
{option_value, options} =
348+
case List.keytake(options, :value, 0) do
349+
nil ->
350+
raise ArgumentError,
351+
"expected :value key when building <option> from keyword list: #{inspect(options)}"
352+
353+
{{:value, value}, options} ->
354+
{value, options}
355+
end
349356

350357
[acc | option(option_key, option_value, options, selected_values)]
351358

0 commit comments

Comments
 (0)