Looking to create dynamic field associations within resources (Fields not hard-coded). As an example, I have a LineItem which has some basic fields like price and quantity. Some LineItems will have a slight variation, say an extra field for the shipping type or tax class.
What I'd like to do (end goal) is to add dynamic fields to this LineItem resource. When creating this resource, depending on which 'type' you selected, these extra fields would show in the Nova create form.
Some things I've considered:
Create 5 separate models. This seems non-practical and ugly. Perhaps some kind of inheritance?
Create a MetaField resource with a relationship to LineItem. The issue is validation. If an administrator is adding a LineItem manually, depending on the type they select, I would love these extra fields to be available as defaults. Perhaps I would need another table, MetaFieldOptions which would define constraints.
I've considered making my own custom field of fields. A collection (rows) of fields that could be added in-line.
My questions:
Is there a better way of doing option 1, with some kind of inheritance (Including table creation).
Or, can I somehow customize the resource creation forms to facilitate this dynamic presentation of data (Without hacking Nova).
My suggestion to you is to search for Nova packages that address this issue so you can learn quickly and maybe adjust some solution that the community already have done.