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.

Yep. Are you trying to get the data that’s actively being typed into the form? Or when/where?

1 Like

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.