Programming Phoenix LiveView: Use Schemaless Changesets In Liveview - demo adding @form before opening "/promo"

In this section, at the point where it tells the reader to “Start up the server, log in, and point your browser at /promo… You should see the following: [image of the Promo page]” …
… it hasn’t yet gone through the code where you add the form to the socket assigns. So it causes this error:
key :form not found in: %{
socket:
...
Up to this point the PromoLive module only includes a stubbed out mount function:
def mount(_params, _session, socket) do
{:ok, socket}
end
My suggestion would be either putting the instruction to “Start up the server” etc after the form code has been added, or don’t include the @form in the HEEX markup right off the bat.
EDIT:
So actually, right after the code where the @form gets added to the socket, it says “Now that we’ve created a form…and added it to our socket assigns, let’s render it in our template” and then shows the same HEEX markup as before.
So I think this may just be a case where a section got moved from one spot to another and didn’t get deleted from the original spot.
EDIT 2:
Ok yes. The first image of the Promo page doesn’t even include the form fields, but the second one that comes later does. Further evidence that the @form was just left in that first HEEX bit accidentally.
Popular Pragprog topics










Other popular topics










Latest in Pragprog
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm