aidalgol
Poking and peeking form data
How do you peek and poke the (starting) data in a form? I thought it would be in the @changeset assign, but that seems to be an empty changeset until form submission.
I have a form for an application resource that has a one-to-many relationship with another record, and I am trying to use Drab to make the nested form dynamic, with add and remove buttons for this nested resource.
In more concrete terms to make this clearer (hopefully): the application is for managing a livestock auction-house. The main resource is “lots”, but the manager needs to detail each animal in a lot, so the lot schema has a has_many relationship with the “animal” schema. I have managed to get a nested form working with a hard-coded number of animals, and I’m trying to use Drab to give the form add and remove buttons on the animal nested form. I just can’t figure out what you poke when it comes to Ecto/Phoenix forms.
Marked As Solved
aidalgol
OK, I am dumb. The changeset as printed by IO.inspect appears empty because it does not recursively print the nested structs. When I peek @changeset and then pass the data field to IO.inspect, I see the changeset as passed to render/3 in the view.
Also Liked
OvermindDL1
Yep. Are you trying to get the data that’s actively being typed into the form? Or when/where?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









