Skip to content

Change default form action errors when progressively enhanced #7956

@arackaf

Description

@arackaf

Describe the problem

I hope I can convince the maintainers that the default behavior for errors in form actions should be changed.

Currently, if you have a progressively enhanced form (without a custom callback), and it errors, your entire page unloads, and displays the nearest error boundary (if present) or shows a default error page if not.

Errors happen, but there's no way this should be the default behavior. A user should not see their current page unloaded, and replaced with an error page because a form post happened to fail.

Describe the proposed solution

For progressively enhanced forms, if the action fails, leave the form in place, and send the error info into $page.form, and rely on the user to display whatever error ui they'd like.

Anticipating one possible response, this would cause use:enhance to break with default, non-enhanced behavior. If that's a big problem then I would submit (pun!) that a non-enhanced form should probably not redirect to an error page either, if there's an error, but rather re-render the same form, with info about the error, so the user can potentially try again. I led with enhanced forms only since that's what I care about most, and figured that would make this a smaller request; but changing the default behavior of form action errors might be the simpler (and better) solution here.

Alternatives considered

The current workaround is to return a custom callback, and simply not call update().

That works, but it basically makes use:enahnce (by itself) essentially useless, unless you can guarantee that the action will never error out (or you disagree with my premise, and actually want the entire page to unload, and show an error page).

Importance

would make my life easier

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions