
Pistrie
Programming Phoenix LiveView: What should the Rating form look like? (page 216/217)
Currently the component looks like this:
<div>
<.form :let={f} for={@changeset} phx-submit="save" phx-target={@myself} id={@id}>
<.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
]}
/>
<.button phx-disable-with="Saving...">Save</.button>
</.form>
</div>
However this gives me the following error:
Long error inside
key :name not found in: %{__changed__: nil, __given__: %{__changed__: nil, field: {%Phoenix.HTML.Form{source: #Ecto.Changeset, 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, product_id: 1, product: #Ecto.Association.NotLoaded, inserted_at: nil, updated_at: nil}, hidden: [], params: %{}, errors: [], options: [method: "post", id: "rating-form-1", multipart: false, "phx-submit": "save", "phx-target": %Phoenix.LiveComponent.CID{cid: 1}], index: nil, action: nil}, :user_id}, type: "hidden"}, errors: [], field: {%Phoenix.HTML.Form{source: #Ecto.Changeset, 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, product_id: 1, product: #Ecto.Association.NotLoaded, inserted_at: nil, updated_at: nil}, hidden: [], params: %{}, errors: [], options: [method: "post", id: "rating-form-1", multipart: false, "phx-submit": "save", "phx-target": %Phoenix.LiveComponent.CID{cid: 1}], index: nil, action: nil}, :user_id}, id: nil, inner_block: [], label: nil, multiple: false, prompt: nil, rest: %{}, type: "hidden"}What do I do to fix this?
Marked As Solved

SophieDeBenedetto
Author of Programming Phoenix LiveView
The code in the book is working off of an outdated version of LiveView, and you appear to be using a newer version. You might find some help here Programming Phoenix LiveView: promo form requires "to_form" changes (p133) - #4 by SophieDeBenedetto. We are currently hard at work on an upgraded version of the whole book which will available for download in the next few weeks so stay tuned!
Popular Prag Prog topics

This test is broken right out of the box…
— FAIL: TestAgent (7.82s)
agent_test.go:77:
Error Trace: agent_test.go:77
agent_test.go:...
New

page 37
ANTLRInputStream input = new ANTLRInputStream(is);
as of ANTLR 4 .8 should be:
CharStream stream = CharStreams.fromStream(i...
New

Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’.
In particula...
New

Hi! I know not the intentions behind this narrative when called, on page XI:
mount() |> handle_event() |> render()
but the correc...
New

First, the code resources:
Page 237: rumbl_umbrella/apps/rumbl/mix.exs
Note: That this file is missing.
Page 238: rumbl_umbrella/app...
New

On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New

When I run the coverage example to report on missing lines, I get:
pytest --cov=cards --report=term-missing ch7
ERROR: usage: pytest [op...
New

Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
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

@mfazio23
Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New
Other popular topics

If it’s a mechanical keyboard, which switches do you have?
Would you recommend it? Why?
What will your next keyboard be?
Pics always w...
New

I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New

Why, if your answer is yes?
New

Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face:
Perhaps if there’s enough peop...
New
New

Just done a fresh install of macOS Big Sur and on installing Erlang I am getting:
asdf install erlang 23.1.2
Configure failed.
checking ...
New

“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin
Even when you’re ultimately right about what the future ho...
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

Author Spotlight:
Karl Stolley
@karlstolley
Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

Author Spotlight:
Tammy Coron
@Paradox927
Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim