Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroPlatform OroPlatform – How do I? Questions How to use comments in custom entity

This topic contains 3 replies, has 3 voices, and was last updated by  sandraa 2 years, 4 months ago.

  • Creator
  • #62472
    Stepan Yudin
    Stepan Yudin

    Hi, yesterday i had a small problem: Comments are used only with any activity entity. I had to connect Comment functional to a simple custom entity without any activities linked to it.
    So, here is my solution. It looks a little dirty but it works in a minutes

    1) Create a migration for you custom entity to link it with comments. See this migration example
    2) In your entity view template (e.g. YourBundle/Resources/views/YourEntity/view.html.twig) add these lines:

    {% import 'OroEntityConfigBundle::macros.html.twig' as entityConfig %}

    After running migration you will see a new “comments” tab in your entity view action.
    P.S.: Tested only in BAP 1.8

    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #62473
    Ivan Klymenko
    Ivan Klymenko

    Hi Stepan, thanks for the provided solution!

    I just want to add a few details.
    The first thing that should be mentioned is that now there is no restrictions to use comments only with activities, so you are able to use this functionality with any entity.

    So few tips, on how to add comments to an entity:

    – you can use the comments functionality with an entity if you will follow the guide described here and extend the view template from OroUIBundle:actions:view.html.twig. If you want to create your own template, you also have to add the render of your comments by yourself.

    As of v1.8, to enable possibility to add comments functionality to the entity from the entity management UI you just have to make your entity configurable.

    Otherwise you have to create the same migration as mentioned in the previous post.

    – Also, after the 1.8 release it is possible to create a custom entity using entity management and enable comments at the first step.

    Stepan Yudin
    Stepan Yudin

    Thank you, Ivan, thats great.
    Entity management interface is really powerful tool, but in my case i need to enable comments at the bundle installation level and only custom migration can help me)

    Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform



    Thank you.. thats great


Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.