I need a way to show a form representing a table in database which make me easily connect a one-to-many relation.
Lets make an easy example:
We have two tables: person and car. Each person can have many cars. The form for adding new persons must have a way to select a variable amount of cars for that person.
Is there anything build in to handle this relation in a form, or is there any extension that can help?
(I’m tired of writing this kind of code over and over again for every time I need this)
I built my own solution around giix, which provides a method saveWithRelated().
As for the user interface I usually go with my own EDataTables extension with selectable rows for very complex relations or a simpler multiselect (using select2) or even a checkbox list.
When I also need to allow adding new records I used to load the related form in a dialog and save it temporarily in session or serialized in a hidden field. Then after saving the main form I would save all the new related records setting the FK to a proper value.