In the examples for using mix phx.gen.html (and gen.schema) the schema usually has only one or two fields, e.g. from the docs:
mix phx.gen.html Accounts User users name:string age:integer
If I want to create a context and schema with more fields (~30), is there another way to get the CRUD generation aside from typing out everything at the command line (with potential typos)?
I can think of three options:
- provide a file for input to mix phx.gen.html. Is that possible?
- Alternatively, create a smaller schema with the generator and do migrations and bit of schema and heex edting to add everything else, which misses out on the convenience of the generator.
- As mentioned above, carefully type out the entire mix gen command and hope all goes well.
Is there a best practice or common way to do this?
The goal behind this is to create work request, something like:
mix gen.phx.html Request Submission submissions name:string date:date
…and so forth with many fields.
I realize the default templates may look unwieldy, but this is a quick and dirty demo to get user feedback.
Thanks for any guidance!