Problem/Motivation
It can sometimes be advantageous to relate two Drupal entities based on a foreign key relationship between properties in their base table. One example of this is with the use of the Data module, where tables of data may be adopted, but often these can be derived from Drupal tables, views, or simply imported data with some known relationship to Drupal. Also, sometimes one may wish to link pieces of data on an un-conventional manner, not supported by Entity Reference, for example, timeseries data. When working with timeseries data it can be useful to allow simultaneous editing of data that occurs on the same date/timestamp, rather than some common entity ID attribute.
Proposed resolution
Introduce a simple getter "fk_getter" for foreign key relationships between two Entity base tables.
Remaining tasks
Initial CodingInitial Testing by developer- Review & testing by others
- Documentation
User interface changes
None
API changes
None
Data model changes
None
Original report by [username]
n/a
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | flexiform-add-fk-entity-2634848_06.patch | 3.86 KB | robertwb |
| #2 | flexiform-add-fk-getter_2634848-02.patch | 1.26 KB | robertwb |
Comments
Comment #2
robertwb commentedAdding an initial patch here to see if there is any wider spread interest. The patch works as advertised, tested on 2 installs that I maintain. The specification of the PK & FK fields is currently a text box, which definitely needs to be a drop-down select for security and stability, but for testing purposes this works.
I am having trouble adding the include file that powers this getter, however. I followed the instructions on , but cannot seem to get it t o add the file contents to the diff. I am pasting it below, and would be delighted to get some guidance from someone.
Comment #3
rlmumfordHi robertwb, your patch doesn't include the class you're trying to add. I suggest you put it in the fk.form_entity.inc underneath includes/form_entity and add that to the modules .info file.
The class you have copied into your comment is exactly the same as class that already exists in the module and, in Drupal 7, all classes need to have unique names. This may be why you can't get the class to load.
I hope that helps.
Comment #4
robertwb commentedHey @rlmumford - thanks for the response and sorry to delay so long before getting back to this. The class name duplication that you pointed out, I accidentally pasted the wrong code in here, and so that is not a problem. In the interim, I also figured out how to get a new file added to a git patch, so, I moved past that step as well. I still have some bugs to work through on this, but will be following back. Thanks again.
Comment #5
robertwb commentedComment #6
robertwb commentedAttached patch adds include files and necessary adjustments to the .info and .inc files to enable for all installs. This is a very simple implementation that assumes the table to be joined:
Potential application of this with Data module to provide editing.
Comment #7
robertwb commented