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.