Sylius: How to inject data variable of it’s own record in a grid rendering

I want to add something to the displaying of the channel of an order grid in admin view depending on some of the products within that order. I would need a way to inject the data of the record into the twig template in example.

Can’t figure it out. The grid looks like this:

sylius_grid:
    grids:
        sylius_admin_order:
            driver:
                name: doctrine/orm
                options:
                    class: "%sylius.model.order.class%"
                    repository:
                        method: createListQueryBuilder
            sorting:
                number: desc
            fields:
                ...
                channel:
                    type: twig
                    label: sylius.ui.channel
                    sortable: channel.code
                    options:
                        template: "@SyliusAdmin/Order/Grid/Field/channel.html.twig"

I see that in other columns they add vars: under options: in example like this:

                    options:
                        template: ...
                        vars: 
                            labels: "@SyliusAdmin/Order/Label/State"

but how to do it with itself, I mean with the rest of the data from the record?
I would need something like this:

                    options:
                        template: "@SyliusAdmin/Order/Grid/Field/channel.html.twig"
                        vars: 
                            order: self

Does anyone know a way to do that?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *