OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums 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 8 years, 5 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #36076

    Stepan Yudin
    Participant

    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
    https://github.com/stepansib/sf-oro-docker

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #36077

    Ivan Klymenko
    Spectator

    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.

    #36078

    Stepan Yudin
    Participant

    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
    https://github.com/stepansib/sf-oro-docker

    #36079

    sandraa
    Participant

    Thank you.. thats great

    BLESS YOU

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

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top