Current section

Files

Jump to
ash_phoenix usage-rules debugging_form_submissions.md
Raw

usage-rules/debugging_form_submissions.md

<!--
SPDX-FileCopyrightText: 2020 Zach Daniel
SPDX-License-Identifier: MIT
-->
# Debugging Form Submission
Errors on forms are only shown when they implement the `AshPhoenix.FormData.Error` protocol and have a `field` or `fields` set.
Most Phoenix applications are set up to show errors for `<.input`s. This can some times lead to errors happening in the
action that are not displayed because they don't implement the protocol, have field/fields, or for a field that is not shown
in the form.
To debug these situations, you can use `AshPhoenix.Form.raw_errors(form, for_path: :all)` on a failed form submission to see what
is going wrong, and potentially add custom error handling, or resolve whatever error is occurring. If the action has errors
that can go wrong that aren't tied to fields, you will need to detect those error scenarios and display that with some other UI,
like a flash message or a notice at the top/bottom of the form, etc.
If you want to see what errors the form will see (that implement the protocl and have fields) use
`AshPhoenix.Form.errors(form, for_path: :all)`.