Announcement

Collapse
No announcement yet.

How to create a link field that reads its value from the parent?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create a link field that reads its value from the parent?

    Hello. I have two entities, let's say Parent and Child. Parent has a link to another entity, let's call it Company. In the Child entity, I have a few read-only varchar fields, which I've modified in the metadata JSON to use "select" and it reads the parent values correctly, but I also have a link field, to Company, which I'd like to reflect the parent's Company, and I don't know how to do that. As you can tell, for the Child entity, these fields are strictly informative, and if they need to be edited, they can be edited in the Parent entity. Is there a way to do this? Perhaps I'd need to create a SelectManager? Is there an existing example? Thank you.
    Last edited by vampirefrog; 02-08-2018, 10:55 AM.

  • #2
    I only needed this in detail view, so in custom/Espo/Custom/Repositories/Child.php i overrode getEntityById and there I used $this->getEntityManager->getEntity('Parent', $child->get('parentId')) and then $child->set('companyId', $parent->get('companyId')); $child->set('companyName', $parent->get('companyName'));.

    Comment

    Working...
    X