Skip to content

Phoenix.HTML.Form.form_for/4 is not working with Changeset #85

Closed
@eniolopes

Description

@eniolopes

According to the documentation here, form_for/4 receives the Ecto.Changeset and converts it to a form, which is passed to the function as the argument f.

I'm following the Programming Phoenix book building the Rumbl application, when rendering the user form I'm getting the following error:

[error] #PID<0.372.0> running Rumbl.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /users/new
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol Phoenix.HTML.FormData not implemented for %Ecto.Changeset{action: nil, changes: %{}, constraints: [], errors: [], filters: %{}, model: %Rumbl.User{__meta__: #Ecto.Schema.Metadata<:built>, id: nil, inserted_at: nil, name: nil, password: nil, password_hash: nil, updated_at: nil, username: nil}, optional: [], opts: [], params: nil, prepare: [], repo: nil, required: [:name, :username], types: %{id: :id, inserted_at: Ecto.DateTime, name: :string, password: :string, password_hash: :string, updated_at: Ecto.DateTime, username: :string}, valid?: false, validations: [username: {:length, [min: 1, max: 20]}]}
        (phoenix_html) lib/phoenix_html/form_data.ex:1: Phoenix.HTML.FormData.impl_for!/1
        (phoenix_html) lib/phoenix_html/form_data.ex:15: Phoenix.HTML.FormData.to_form/2
        (phoenix_html) lib/phoenix_html/form.ex:234: Phoenix.HTML.Form.form_for/4
        (rumbl) web/templates/user/new.html.eex:2: Rumbl.UserView."new.html"/1
        (rumbl) web/templates/layout/app.html.eex:29: Rumbl.LayoutView."app.html"/1
        (phoenix) lib/phoenix/view.ex:344: Phoenix.View.render_to_iodata/3
        (phoenix) lib/phoenix/controller.ex:633: Phoenix.Controller.do_render/4
        (rumbl) web/controllers/user_controller.ex:1: Rumbl.UserController.action/2
        (rumbl) web/controllers/user_controller.ex:1: Rumbl.UserController.phoenix_controller_pipeline/2
        (rumbl) lib/phoenix/router.ex:261: Rumbl.Router.dispatch/2
        (rumbl) web/router.ex:1: Rumbl.Router.do_call/2
        (rumbl) lib/rumbl/endpoint.ex:1: Rumbl.Endpoint.phoenix_pipeline/1
        (rumbl) lib/plug/debugger.ex:93: Rumbl.Endpoint."call (overridable 3)"/2
        (rumbl) lib/phoenix/endpoint/render_errors.ex:34: Rumbl.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Not sure what I'm missing, I don't see a defimpl for Ecto.Changeset on Phoenix.HTML.FormData

I'm using Elixir 1.2.5 with Phoenix 1.1.5.

I'm probably missing something really simple.

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