File tree Expand file tree Collapse file tree
lib/polymorphic_embed/html Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,11 +49,11 @@ if Code.ensure_loaded?(Phoenix.HTML) && Code.ensure_loaded?(Phoenix.HTML.Form) d
4949 form . source . data . __struct__
5050 end
5151
52- def to_form ( % { action: parent_action } = source_changeset , form , field , options ) do
52+ def to_form ( source_changeset , % { action: parent_action } = form , field , options ) do
5353 id = to_string ( form . id <> "_#{ field } " )
5454 name = to_string ( form . name <> "[#{ field } ]" )
5555
56- params = Map . get ( source_changeset . params || % { } , to_string ( field ) , % { } ) |> List . wrap ( )
56+ params = Map . get ( source_changeset . params || % { } , to_string ( field ) , % { } )
5757
5858 struct = Ecto.Changeset . apply_changes ( source_changeset )
5959
@@ -71,7 +71,17 @@ if Code.ensure_loaded?(Phoenix.HTML) && Code.ensure_loaded?(Phoenix.HTML.Form) d
7171 list_data
7272 |> Enum . with_index ( )
7373 |> Enum . map ( fn { data , i } ->
74- params = Enum . at ( params , i ) || % { }
74+ params =
75+ case params do
76+ nil ->
77+ % { }
78+
79+ params when is_list ( params ) ->
80+ Enum . at ( params , i ) || % { }
81+
82+ params when is_map ( params ) ->
83+ Map . get ( params , to_string ( i ) , % { } )
84+ end
7585
7686 changeset =
7787 data
You can’t perform that action at this time.
0 commit comments