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
As per the title, thanks.
New
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
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
Page 28: It implements io.ReaderAt on the store type.
Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt?
...
New
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions:
In Gemfile, change
gem 'rails'
t...
New
#book-python-testing-with-pytest-second-edition
Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint.
As entered, the SwitchCompat changes color to hol...
New
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
The test is as follows:
Scenario: Intersecting a scaled sphere with a ray
Given r ← ray(point(0, 0, -5), vector(0, 0, 1))
And s ← sphere...
New
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
Other popular topics
Ruby, Io, Prolog, Scala, Erlang, Clojure, Haskell. With Seven Languages in Seven Weeks, by Bruce A. Tate, you’ll go beyond the syntax—and...
New
Write Elixir tests that you can be proud of. Dive into Elixir’s test philosophy and gain mastery over the terminology and concepts that u...
New
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it.
Does your monitor have eye p...
New
From finance to artificial intelligence, genetic algorithms are a powerful tool with a wide array of applications. But you don't need an ...
New
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
Author Spotlight
Mike Riley
@mriley
This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
New
Hair Salon Games for Girls Fun
Girls Hair Saloon game is mainly developed for kids. This game allows users to select virtual avatars to ...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /emacs
- /haskell
- /typescript
- /svelte
- /onivim
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /vscode
- /flutter
- /ash
- /html
- /deepseek
- /opensuse
- /zig
- /centos
- /php
- /scala
- /react-native
- /lisp
- /textmate
- /sublime-text
- /nixos
- /debian
- /agda
- /deno
- /django
- /kubuntu
- /arch-linux
- /nodejs
- /ubuntu
- /spring
- /revery
- /manjaro
- /diversity
- /julia
- /lua
- /laravel
- /markdown









