Getting "protocol Phoenix.HTML.FormData not implemented" from `phx.gen.live` generated code

Hi. I ran this command:

mix phx.gen.live Forms Form forms domain:string bg_color:string primary_color:string title:string description:text

Then ran the migrations and added routes to the web scope.

However, when I try to visit the /forms/new route, I’m getting this error:

protocol Phoenix.HTML.FormData not implemented for %MyProject.Forms.Form{__meta__: #Ecto.Schema.Metadata<:built, "forms">, id: nil, domain: nil, description: nil, title: nil, bg_color: nil, primary_color: nil, inserted_at: nil, updated_at: nil} of type SuperSubstack.Forms.Form (a struct). This protocol is implemented for the following type(s): Ecto.Changeset, Map

I haven’t made any changes besides the generated code, so surprised to see this error. Any idea why it’s there and the ways to fix it? Maybe there is a name collision of some sort? (“form”)

It indeed was a name collision. Using a different name for that schema solves the issue.

mix phx.gen.live Forms SubscriptionForm forms name:string

i.e. SubscriptionForm instead of Form.

Reported at Using "Form" as a schema name in `phx.gen.live` causes components to misbehave · Issue #3350 · phoenixframework/phoenix_live_view · GitHub