Phoenix.HTML.Form has two errors fields when validating?

So first let’s format that output:

%Phoenix.HTML.Form{
  data: %{},
  errors: [],
  hidden: [],
  id: "user",
  impl: Phoenix.HTML.FormData.Plug.Conn,
  index: nil,
  name: "user",
  options: [class: "settings-form"],
  params: %{
    "email" => "",
    "first_name" => "",
    "last_name" => "",
    "password" => "",
    "password_confirmation" => ""
    },
  source: %Plug.Conn{
    adapter: {Plug.Adapters.Cowboy.Conn, :...},
    assigns: %{
      changeset: #Ecto.Changeset<
        action: :insert,
        changes: %{username: ""},
        errors: [
          first_name: {"can't be blank", [validation: :required]},
          last_name: {"can't be blank", [validation: :required]},
          email: {"can't be blank", [validation: :required]},
          password: {"can't be blank", [validation: :required]},
          password_confirmation: {"can't be blank", [validation: :required]}
          ],
        data: #Go2sci.User<>,
        valid?: false
        >,
      layout: {Go2sci.LayoutView, "app.html"},
      title: "Register"
    },
    ...

So, looking at this it is now obvious that the %Phoenix.HTML.Form{} only has one errors entry, and it is indeed an empty list. The form holds information from where this information came from in its source key, thus being the same %Plug.Conn{} that is passed everywhere in your pipeline. Your %Plug.Conn{} has a key called assigns that anything, you, a plug, whatever, can store temporary information on that may be useful later on in the pipeline, in this assigns there is a user/plug-added key called errors, this one is entirely different from the errors on the %Phoenix.HTML.Form{} of course, since different objects, however this key’s value appears to have the information you are missing.

Now, this says two things to me:

  1. A put_assign/3 is called somewhere in your pipeline that is adding the :errors key, why? No clue.
  2. You are giving the form your plug instead of your changeset, you probably want to give it your changeset, not your plug. :slight_smile:

EDIT: Also, the linked github issue is entirely unrelated. :slight_smile: