Fix: form_for deprecation warning (#84)

This commit is contained in:
Darren Black 2023-03-28 15:45:00 +11:00 committed by GitHub
parent 0dea54b575
commit 1a1ff1a568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -930,7 +930,7 @@ defmodule AshPhoenix.FilterForm do
impl: __MODULE__, impl: __MODULE__,
id: opts[:id] || form.id, id: opts[:id] || form.id,
name: opts[:as] || form.name, name: opts[:as] || form.name,
errors: [], errors: opts[:errors] || [],
data: form, data: form,
params: form.params, params: form.params,
hidden: hidden, hidden: hidden,
@ -945,10 +945,21 @@ defmodule AshPhoenix.FilterForm do
|> Enum.map(fn {component, index} -> |> Enum.map(fn {component, index} ->
name = Map.get(component, :name, phoenix_form.name) name = Map.get(component, :name, phoenix_form.name)
Phoenix.HTML.Form.form_for(component, "action", case component do
transform_errors: form.transform_errors, %AshPhoenix.FilterForm{} ->
as: name <> "[components][#{index}]" to_form(component,
) as: name <> "[components][#{index}]",
id: component.id,
errors: AshPhoenix.FilterForm.errors(component)
)
%AshPhoenix.FilterForm.Predicate{} ->
Phoenix.HTML.FormData.AshPhoenix.FilterForm.Predicate.to_form(component,
as: name <> "[components][#{index}]",
id: component.id,
errors: AshPhoenix.FilterForm.errors(component)
)
end
end) end)
end end