Phoenix why not show changeset errors?

You usually don’t just check that the changeset is valid, you do something with it.

The expected usage is something like this:

case Repo.insert(changeset) do
  {:ok, _model} ->
    conn
    |> redirect(to: page_path(conn, :index))
  {:error, changeset} ->
    # Here the changeset has had an action attribute set
    conn
    |> render("new.html", changeset: changeset)
end

The form helper checks that an action was attempted on the changeset.
You can force errors to be shown by adding an action before sending it to the page.

changeset = %{changeset | action: :insert}
15 Likes