I thought I would build upon this week’s earlier example of how to add a flex relate by showing how to add the related subpanels as well. If you remember, we’ve added a new module named test_flexparent, which relates to either the Contacts or Leads module. In order to setup subpanels to show related test_flexparent records in the detail views of the Contacts and Leads modules, you’ll just need to add the subpanel definitions for each module. Let’s look how for the Contacts module.
First, we need to add a link field that handles the relationship, just like we did in the previous post on the test_flexparent module side. To do this, add in a file named custom/Extension/modules/Contacts/Ext/Vardefs/flexrelate.php with the following contents:
Now, we just need to define the subpanel. Just add the following contents into a file named custom/Extension/modules/Contacts/Ext/Layoutdefs/forflexrelate.php:
Lastly, we just need to add a language string for the subpanel’s title. Make a new file named custom/Extension/modules/Contacts/Ext/Language/en_us.flexrelate.php with the following contents to do so.
Now, just do a Quick Rebuild and Repair and the subpanel should appear in the Contacts detailview. The procedure is the same for the Leads module, just exchange the Contact references for Leads ones and you should be all good to go.