Skip to content

Commit

Permalink
fix: spec update_form to accept functions of lists
Browse files Browse the repository at this point in the history
fixes #235
  • Loading branch information
zachdaniel committed Aug 16, 2024
1 parent d24129e commit 6d68aa3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/ash_phoenix/form/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2168,10 +2168,24 @@ defmodule AshPhoenix.Form do
This can be useful if you have a button that should modify a nested form in some way, for example.
"""
@spec update_form(t(), path(), (t() -> t())) :: t()
@spec update_form(Phoenix.HTML.Form.t(), path(), (t() -> t())) :: Phoenix.HTML.Form.t()
@spec update_form(
t(),
list(atom | integer) | String.t() | atom,
(t() -> t()) | ([t()] -> [t()])
) ::
t()
@spec update_form(
Phoenix.HTML.Form.t(),
list(atom | integer) | String.t(),
(t() -> t()) | ([t()] -> [t()])
) ::
Phoenix.HTML.Form.t()
def update_form(form, path, func, opts \\ [])

def update_form(form, path, func, opts) when is_atom(path) do
update_form(form, [path], func, opts)
end

def update_form(%Phoenix.HTML.Form{} = form, path, func, opts) do
form.source
|> update_form(path, func, opts)
Expand Down

0 comments on commit 6d68aa3

Please sign in to comment.