arcanemachine
Programming Phoenix LiveView B9.0: (Form Episode 3) Form code syntax does not work as written (p. 216/217) (PDF)
This is the same issue as this one (I’ll call it Form Episode 2) and this one (I’ll call it Form Episode 1). Unsurprisingly, it requires the same solution as the other 2 issues.
On page 216/217, the following code produces an error:
<.input field={{f, :user_id}} type="hidden" />
<.input field={{f, :product_id}} type="hidden" />
<.input field={{f, :stars}} type="rating" prompt="Rating"
options={["★★★★★": 5, "★★★★": 4, "★★★": 3, "★★": 2, "★": 1
]} />
The error reads:
key :name not found in: %{
id: nil,
label: nil,
type: "hidden",
prompt: nil,
field: {%Phoenix.HTML.Form{
source: #Ecto.Changeset<
action: nil,
changes: %{},
errors: [stars: {"can't be blank", [validation: :required]}],
data: #Pento.Survey.Rating<>,
valid?: false
>,
impl: Phoenix.HTML.FormData.Ecto.Changeset,
id: "rating-form-1",
name: "rating",
data: %Pento.Survey.Rating{
__meta__: #Ecto.Schema.Metadata<:built, "ratings">,
id: nil,
stars: nil,
user_id: 1,
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
product_id: 1,
product: #Ecto.Association.NotLoaded<association :product is not loaded>,
inserted_at: nil,
updated_at: nil
},
hidden: [],
params: %{},
errors: [],
options: [
method: "post",
id: "rating-form-1",
multipart: false,
"phx-target": %Phoenix.LiveComponent.CID{cid: 1},
"phx-submit": "save"
],
index: nil,
action: nil
}, :user_id},
errors: [],
rest: %{},
__changed__: nil,
inner_block: [],
__given__: %{
type: "hidden",
field: {%Phoenix.HTML.Form{
source: #Ecto.Changeset<
action: nil,
changes: %{},
errors: [stars: {"can't be blank", [validation: :required]}],
data: #Pento.Survey.Rating<>,
valid?: false
>,
impl: Phoenix.HTML.FormData.Ecto.Changeset,
id: "rating-form-1",
name: "rating",
data: %Pento.Survey.Rating{
__meta__: #Ecto.Schema.Metadata<:built, "ratings">,
id: nil,
stars: nil,
user_id: 1,
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
product_id: 1,
product: #Ecto.Association.NotLoaded<association :product is not loaded>,
inserted_at: nil,
updated_at: nil
},
hidden: [],
params: %{},
errors: [],
options: [
method: "post",
id: "rating-form-1",
multipart: false,
"phx-target": %Phoenix.LiveComponent.CID{cid: 1},
"phx-submit": "save"
],
index: nil,
action: nil
}, :user_id},
__changed__: nil
},
multiple: false
}
To fix the error, change the offending lines to read:
<.input field={f[:user_id]} type="hidden" />
<.input field={f[:product_id]} type="hidden" />
<.input field={f[:stars]} type="rating" prompt="Rating"
options={["★★★★★": 5, "★★★★": 4, "★★★": 3, "★★": 2, "★": 1
]} />
Marked As Solved
SophieDeBenedetto
Author of Programming Phoenix LiveView
Thanks for your feedback here. This and all other forms are being updated to work with the latest version of LiveView as we speak. We’ll be release a new Beta version of the book in the next few weeks.
Popular Pragmatic Bookshelf topics
Hi everyone!
There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
Hi,
build fails on:
bracket-lib = “~0.8.1”
when running on Mac Mini M1 Rust version 1.5.0:
Compiling winit v0.22.2
error[E0308]: mi...
New
The generated iex result below should list products instead of product for the metadata. (page 67)
iex> product = %Product{}
%Pento....
New
Hello! Thanks for the great book.
I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
It seems the second code snippet is missing the code to set the current_user:
current_user: Accounts.get_user_by_session_token(session["...
New
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
AWDWR 7, page 152, page 153:
Hello everyone,
I’m a little bit lost on the hotwire part. I didn’t fully understand it.
On page 152 @rub...
New
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
Other popular topics
Stop developing web apps with yesterday’s tools. Today, developers are increasingly adopting Clojure as a web-development platform. See f...
New
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first:
asdf plugin-upd...
New
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol:
bre...
New
Author Spotlight
Rebecca Skinner
@RebeccaSkinner
Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
Node.js v22.14.0 has been released.
Link: Release 2025-02-11, Version 22.14.0 'Jod' (LTS), @aduh95 · nodejs/node · GitHub
New
Fight complexity and reclaim the original spirit of agility by learning to simplify how you develop software. The result: a more humane a...
New
Use advanced functional programming principles, practical Domain-Driven Design techniques, and production-ready Elixir code to build scal...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /java
- /clojure
- /emacs
- /haskell
- /typescript
- /svelte
- /onivim
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /vscode
- /flutter
- /html
- /ash
- /deepseek
- /zig
- /opensuse
- /centos
- /php
- /react-native
- /scala
- /lisp
- /sublime-text
- /textmate
- /nixos
- /debian
- /agda
- /deno
- /django
- /kubuntu
- /arch-linux
- /nodejs
- /spring
- /ubuntu
- /revery
- /manjaro
- /lua
- /diversity
- /julia
- /quarkus
- /markdown









