How to manage embedded schema in generators and form?

Hi everybody!

How do you handle embedded schemas (the map fields in JSON or JSONB) with generators and forms?
I have a situation where I have one schema (Account) that will have some embedded schemas (MemberS, Contact).
I’m going with embedded schema because I’m not sure of how the underlying data will end up.

But I have two questions about embedded schemas:

  • How to handle them using generators (particularly mix.gen.html)?
    I guess that ignoring the field and populating manually should be the easiest but then I would have to generate every bit of HTML…
  • Should I use form_for or inputs_for?

Also I’ll probably go with a JS solution that will add more fields for the Members since I’ll have embeds_many for this. But what will be the id and name fields I should set manually?
I remember having some very hard time in Rails for (and I’m not even talking about casting datas) despite those kind of form management should be trivial (at least for a web application)…

Hopefully I think it will be easier with Phoenix and Ecto Changeset…

2 Likes

Hi, I’m having the same issue.
Have you solved yours ?