Jump.CredoChecks.LiveViewFormCanBeRehydrated (Jump.CredoChecks v0.3.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Ensures that all forms with phx-submit have both an id and phx-change attribute specified.

This is critical for form rehydration, since LiveView can't maintain form state across deploys or reconnects without an ID and phx-change, leading to the form being totally reset. Forms without phx-submit are not LiveView forms and don't need these attributes.

✅ Good:

<.form id="user-form" phx-submit="save" phx-change="validate">`

❌ Bad (missing ID and phx-change):

<.form phx-submit="save">

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.