ostap

ostap

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”)

Marked As Solved

ostap

ostap

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 #5871 · phoenixframework/phoenix · GitHub

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement