![]() Given the variety of changes that are sometimes required, the real test has to be what the user sees. Note these tests check what appears in the HTML output. Here is the commit corresponding to this version of the writeup: Because a lot of flailing went into getting all this to work, the code is kind of embarrassing. I would very much like to see counterexamples. It seems like that is cutting against the grain of the Ecto framework. ![]() It bothers me that so much knowledge about how to handle forms gets pushed down close to the layout of Ecto schemas, which seem like they should only be about the business domain.īut every time I try to migrate form-handling considerations closer to the crit_web controller layer, I get into problems. That is, the fact that the enclosing Animal changeset has :valid set to false prevents the enclosed inputs_for from adding an empty subform. That's because inputs_for does not obey :prepend if the changeset has an error. Note that the same trickery would be required if the :prepend option were given to inputs_for. An animal with its loaded associations looks like something like this: % There are two Postgres tables (and, so, Ecto schemas) involved. I welcome comments and would be happy to rewrite my code and this example based on them. ![]() If you want to do something similar, this post may be of use. This post at least provides a line in the sand that I can revisit as I build up more experience in using and observing changesets in the wild.It took me some time to get the server-side code behind the following form working. It feels like it has been caught between two opposing principles and has thus been pulled in two different directions.Ĭhangesets want to offer welcome convenience in building web applications and they want to follow the Elixir and Phoenix principles of separation of concerns and decoupled code. It doesn’t decompose as neatly as I might like.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |