Since the workorder to checklist relationship is 1 to 1 (for each type of checklist) it doesn't fit the mold of a typical relationship (they are generally 1 to n).
There are a few ways to work with this type of setup. Some that come to mind are:
1. Create separate relationships for each type of checklist. Use the action:condition directives in each's relationships.ini file to hide/show them appropriately depending on which relationship should be active at any given time. You could still use the grid widget for editing each of these relationships (and use javascript to hide show the appropriate fields when options are changed on the workorder form). The only thing is that the grid widget is kind of expecting to be able to have multiple rows and in this case that wouldn't happen - so I'm not sure what the outcome would be.
2. Use the __join__ feature (scarcely documented at this time) of Xataface and specify each checklist as a join table of the workorder table. You would do this by adding a section to the workorders fields.ini file:
- Code: Select all
[__join__]
checklist_general="General Checklist"
checklist_deflib="DefLib Checklist"
... etc..
This would create subtabs in your edit form for "General Checklist" and "Deflib Checklist" with separate forms that edit those records. For this to work, however, it assumes that the primary key of the "join" tables correspond to the primary key of the source table. So your primary key for the checklist tables would have to be workorder_id. (I must ask, if a checklist is going to be unique on workorder_id, why not just use the workorder_id as the primary key and do away with the list_id?)
This solution wouldn't correspond with using the grid widget though.
3. Create transient fields on the workorder form, and use the afterSave() or beforeSave() methods to update the appropriate checklist table depending on the values of these transient fields. You'd also have to worry about setting the default values of these fields.
4. Use custom blocks/slots to add your own custom fields on the edit form for workorder, and use the beforeSave() trigger to update the database with input from your custom fields.
5. Don't have the tables related directly at all.. just add links in logical places of the interface to link to the appropriate checklist form.