Support

Account

Home Forums Feature Requests View Related Records Reply To: View Related Records

  • Hello…

    Good question…. here’s how I might tackle it…

    First… as we know…

    We have a ‘Doctors’ CPT
    … with a ‘Locations’ Relationship field.

    This ‘Locations’ field may have a series of Location IDs (say: 5, 6, 7)

    Now, we have the ‘Locations’ CPT

    When looking at ‘Edit Locations’
    … we could have a ‘Doctors’ Relationship field here.
    In it… we could work this hook
    … to fetch all the Docs that are attached to that Location.

    Now, as an alternative… if you just wanted to do this for ‘Display’ purposes, you can pre-populate another field with the doc data… just use some other field type other than Relationship… like the ‘Enhanced Message’ add-on that allows for PHP, or maybe some other built-in field type like textarea, and make it read-only. Example here for making it read-only.

    But… it’s better probably to use a Relationship field to make for smarter editing. But we have to keep the data in synch on our own from the way I understand it. So… each time a change is made to the ‘Doctors’ Relationship field when editing ‘Locations’, you can write logic that loops through and updates the ‘Doctors’ records (i.e. adds a location or removes a location).

    Now, I haven’t thought far enough ahead to point you how to do the last part, because I’m not sure you wanted to get this far down the rabbit hole 🙂 Let me know!