Skip to content

Commit 978a57a

Browse files
committed
Handle :hr in keyword lists
1 parent 8cfd3e3 commit 978a57a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/phoenix_html/form.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,11 @@ defmodule Phoenix.HTML.Form do
380380
{value, options}
381381
end
382382

383-
[acc | option(option_key, option_value, extra ++ options, selected_values)]
383+
if option_key == :hr do
384+
[acc | hr_tag()]
385+
else
386+
[acc | option(option_key, option_value, extra ++ options, selected_values)]
387+
end
384388

385389
:hr, acc ->
386390
[acc | hr_tag()]

test/phoenix_html/form_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,19 @@ defmodule Phoenix.HTML.FormTest do
294294
~s(<hr/>) <>
295295
~s(<option value="new">New</option>)
296296

297+
assert options_for_select(
298+
[
299+
[key: "First", value: "first"],
300+
[key: :hr, value: nil],
301+
[key: "Last", value: "last"]
302+
],
303+
nil
304+
)
305+
|> safe_to_string() ==
306+
~s(<option value="first">First</option>) <>
307+
~s(<hr/>) <>
308+
~s(<option value="last">Last</option>)
309+
297310
assert options_for_select(
298311
[
299312
{"Open", ~U[2025-01-01 06:30:00.000000Z]},

0 commit comments

Comments
 (0)