From 8ccbed8f0651feaf6a5c2c83024a7f4c10ad0807 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Mon, 5 Feb 2024 19:58:57 -0500 Subject: [PATCH] chore: draw the rest of the owl on ensure_can_submit --- lib/ash_phoenix/form/form.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ash_phoenix/form/form.ex b/lib/ash_phoenix/form/form.ex index 0f20f7f..7bc0ea7 100644 --- a/lib/ash_phoenix/form/form.ex +++ b/lib/ash_phoenix/form/form.ex @@ -630,7 +630,7 @@ defmodule AshPhoenix.Form do end @spec can_submit?(t()) :: boolean() - @spec can_submit?(Phoenix.HTML.Form.t(), Keyword.t()) :: Phoenix.HTML.Form.t() + @spec can_submit?(Phoenix.HTML.Form.t()) :: boolean def can_submit?(%Phoenix.HTML.Form{} = form) do can_submit?(form.source) @@ -650,6 +650,12 @@ defmodule AshPhoenix.Form do form.source.api.can?(form.source, form.source.context[:private][:actor]) end + @spec ensure_can_submit!(t()) :: t() + @spec ensure_can_submit!(Phoenix.HTML.Form.t()) :: Phoenix.HTML.Form.t() + def ensure_can_submit!(%Phoenix.HTML.Form{} = form) do + %{form | source: ensure_can_submit!(form.source)} + end + def ensure_can_submit!(form) do unless form.source.api do raise """