Espocrm custom layout for relationship

April 22, 2024

Espocrm layout system has two types of layouts

  • Detail Layout
  • List Layout

And by default provides four layouts for every entity as following:

  • List: used in the main list screen
  • Small List: used in relationship panels
  • Detail: use in main details screen
  • Small Detail: used in modal detail views (quick views).

Sometimes you need to have custom list layout for specific relationship panel rather than using the default small list for all relationship panels.

These are the steps:

let’s say you have MainEntity has relation with SubEntity and you want to customize the list of SubEntity inside the MainEntity

  • adding additional layout go to this file or add it if not exist:
/custom/Espo/Custom/Resources/metadata/clientDefs/SubEntity.json

{
    .......
    "additionalLayouts": {
        "customList": {
            "type": "list"
        }
    },
    .......
}
  • create this file:
custom/Espo/Custom/Resources/layouts/MainEntity/customList.json
[
    {"name":"name"}
]
  • now in the Main Entity client defs add this:
   "relationshipPanels": {
      "subEntities":{
         "layout":"customList"
      }
   },
   .......
}
  • go to the layout manager to customize the new added layout