I have an entity with related entities in ORO platform. Built-in User
entity can have many built-in Access Roles
. I want to display those roles in Users datagrid using custom twig template so I can wrap them in some labels or styling.
This is my section datagrids.yaml that overrides the default users datagrid:
users-grid:
source:
query:
select:
- What to pass here?
join:
left:
- { join: u.roles, alias: r }
groupBy: u.id
columns:
roles:
inline_editing:
enable: false
label: 'Roles'
type: twig
frontend_type: html
template: 'MyBundle:User:Property/roles.html.twig'
What do I have to do to be able to access Collection of Role object in roles.html.twig
?
It's not possible to do just with the YAML configuration. Instead, you have to create a datagrid listener that will populate the roles column with the data on the "result after" event. Here is an example: